DEV Community

Alex Spinov
Alex Spinov

Posted on

Hurl Has a Free API: Test HTTP APIs With Plain Text Files

Hurl is a command-line tool for running HTTP requests defined in plain text. Think cURL but with assertions, variables, and chaining for API testing.

Why Hurl Matters

Postman is heavy. cURL is hard to read. Hurl files are plain text that anyone can understand, version in git, and run in CI/CD.

What you get for free:

  • Plain text HTTP request files
  • Built-in assertions (status, headers, body, JSONPath)
  • Variable capture and chaining
  • Cookie and session handling
  • Run in CI/CD (exit code on failure)
  • HTML and JUnit test reports

Quick Start

curl -fsSL https://hurl.dev/install.sh | sh
hurl api-tests.hurl
hurl --test --report-html report/ api-tests.hurl
Enter fullscreen mode Exit fullscreen mode

Basic Request

GET http://localhost:8080/api/users
HTTP 200
[Asserts]
header "Content-Type" contains "application/json"
jsonpath "$" count > 0
jsonpath "$[0].name" exists

POST http://localhost:8080/api/users
Content-Type: application/json
{
  "name": "Alice",
  "email": "alice@example.com"
}
HTTP 201
[Captures]
user_id: jsonpath "$.id"
[Asserts]
jsonpath "$.name" == "Alice"

GET http://localhost:8080/api/users/{{user_id}}
HTTP 200
[Asserts]
jsonpath "$.name" == "Alice"

DELETE http://localhost:8080/api/users/{{user_id}}
HTTP 204
Enter fullscreen mode Exit fullscreen mode

Variables and Chaining

# Login and capture token
POST http://localhost:8080/api/login
Content-Type: application/json
{
  "email": "admin@example.com",
  "password": "secret"
}
HTTP 200
[Captures]
token: jsonpath "$.token"

# Use token in next request
GET http://localhost:8080/api/protected
Authorization: Bearer {{token}}
HTTP 200
Enter fullscreen mode Exit fullscreen mode

CI/CD Integration

- name: Run API Tests
  run: hurl --test --report-junit results.xml tests/*.hurl
Enter fullscreen mode Exit fullscreen mode

Links


Building API testing pipelines? Check out my developer tools on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)