Skip to content

Migrating from Hurl

Hurl and apic are close cousins: one binary each, plain-text files, captures and assertions. The move is mostly mechanical. A Hurl entry’s sections become # @ directives above an .http request, and the files become ones VS Code, JetBrains and Neovim can send with a click. One thing changes for the better on the way: captures persist between runs, so a single named request can run on its own with the token kept from an earlier run.

Hurlapic
A .hurl filea .http file; apic run file.http runs it top to bottom as a flow
An entry (request plus response section)a ### block with # @name, so it can also run alone
HTTP 200# @assert status == 200
[Captures] token: jsonpath "$.token"# @capture token = body.$.token
header "Location", cookie "sid"header.location, cookie.sid
jsonpath "$.items[0].id"body.$.items[0].id (filters, slices and .. too; see body paths)
status, duration, bodystatus, duration, body
[Asserts] jsonpath "$.id" == 42# @assert body.$.id == 42
==, !=, >, >=, <, <=the same
contains, startsWith, endsWith, matchesthe same names
exists, not existsthe same
isString, isInteger, isBoolean, isCollection, isEmptythe same, with isArray or isObject for isCollection
jsonpath "$.items" count == 3# @assert body.$.items length == 3
[Options] retry: 10 retry-interval: 2000# @retry 10 2s
[Options] delay: 500# @sleep 500ms
[Options] http2: trueGET https://… HTTP/2 on the request line
[Options] insecure: true, cacert, cert, key--insecure, or tls: in apic.yaml and --cacert, --cert, --key
[BasicAuth]# @auth basic user pass
[FormParams], [MultipartFormData]a urlencoded body, or a multipart body
{{name}} with --variable name=value{{name}} with --var name=value
--variables-file vars.envan environment in http-client.env.json, or .env
HURL_name environment variablesAPIC_VAR_name
--test, --globapic run a.http b.http --keep-going
--report-junit, --report-html, --report-jsonapic test --format junit for features; apic run --report report.html; apic run --json
--json (one line per file)apic run --json (one object per request)

A Hurl file against the demo API:

POST http://localhost:8089/auth/login
{"user": "alice", "password": "{{password}}"}
HTTP 200
[Captures]
token: jsonpath "$.access_token"
GET http://localhost:8089/todos?done=false
Authorization: Bearer {{token}}
HTTP 200
[Asserts]
header "X-Total-Count" exists
jsonpath "$" count >= 1
jsonpath "$[0].done" == false
jsonpath "$[0].id" isString

The same two requests in apic (with apic demo running in another terminal). The host moves into the environment, each entry gets a name, and each section line becomes a directive:

Terminal window
mkdir -p from-hurl
cat > from-hurl/http-client.env.json <<'EOF'
{
"local": { "baseUrl": "http://localhost:8089" }
}
EOF
cat > from-hurl/todos.http <<'EOF'
### Log in
# @name login
# @assert status == 200
# @capture token = body.$.access_token
POST {{baseUrl}}/auth/login
Content-Type: application/json
{"user": "alice", "password": "{{password}}"}
### The open todos
# @name open-todos
# @assert status == 200
# @assert header.x-total-count exists
# @assert body.$ length >= 1
# @assert body.$[0].done == false
# @assert body.$[0].id isString
GET {{baseUrl}}/todos?done=false
Authorization: Bearer {{token}}
EOF
apic run todos.http -C from-hurl --env local --var password=s3cret | tail -4
✓ login 200 1 ms
✓ open-todos 200 0 ms
2 passed · 2 requests · 1 ms

Hurl adds Content-Type: application/json to a JSON body by itself; in a .http file, write the header, since editors send exactly what the file says. Then, because the token was captured into the session, the second request runs on its own, with no login in the same run:

Terminal window
apic run open-todos -C from-hurl --env local | tail -1
  • XPath, sha256, md5 and the filter chain (jsonpath "$.x" split "," nth 1). apic’s selectors are JSONPath, headers, cookies, status, duration and the raw body; a check that needs a transformation goes in a shell script around apic run --json.
  • [Options] for curl internals such as compressed, path-as-is or unix-socket. apic is not built on libcurl.
  • --test reports per file. apic reports per request; --keep-going and the summary line give the same pass/fail picture.
  • Hurl’s own format. apic reads .http only; the two formats are close enough that a search-and-replace does most of it.
  • One .http file per .hurl file, a ### block and # @name per entry
  • HTTP <code> to # @assert status == <code>
  • [Captures] to # @capture, [Asserts] to # @assert, jsonpath "$…" to body.$…
  • Hosts to {{baseUrl}} in http-client.env.json; --variables-file to an environment
  • [Options] retry to # @retry
  • A Content-Type header on each JSON body
  • apic validate is clean and apic fmt --check passes
  • hurl --test in CI replaced with apic run *.http --keep-going

See also: the assertion operators, # @retry and apic compared with Hurl.

Hosted on Cloudflare, which keeps aggregate traffic statistics. No cookies, no tracking scripts, no per-request logs. Privacy