How to Use Hurl: A Practical Guide for Developers and Testers
Hurl is a powerful command line tool for making HTTP requests and validating responses using a simple, human readable plain text format. Itβs ideal for API testing, scripting, and automating HTTP interactions.
In this guide, youβll learn what Hurl is, how to install it, and how to write and execute Hurl scripts for various use cases.
When to Use Hurl
When you are shuffling between different tools like curl
, Postman, and pytest
, Hurl should be used.
Table of Contents
π§ What is Hurl?
Hurl is a tool that allows you to:
-
Send HTTP requests (GET, POST, PUT, DELETE, etc.)
-
Define expected responses with assertions (status code, headers, body content)
-
Use variables and capture values from responses
-
Chain multiple requests in a single test scenario
Itβs like a mix between curl
, Postman, and pytest
but with the simplicity of plain text.
π Installation
You can install Hurl on most platforms:
On macOS (via Homebrew):
brew install hurl
On Linux (Debian/Ubuntu):
curl -sSL https://hurl.dev/install.sh | bash
On Windows:
Download the executable from the Hurl releases page and add it to your PATH
.
π Writing a Hurl Script
A Hurl script is a .hurl
file that defines a sequence of HTTP requests and their expected results.
Example: Simple GET Request
GET https://jsonplaceholder.typicode.com/posts/1
HTTP/1.1 200
[Asserts]
jsonpath "$.id" == 1
jsonpath "$.userId" == 1
This script:
-
Sends a GET request
-
Expects HTTP 200 OK
-
Validates JSON fields using JSONPath expressions
βοΈ Features & Syntax
1. Sending POST Requests
POST https://jsonplaceholder.typicode.com/posts
[Headers]
Content-Type: application/json
[Body]
{
"title": "foo",
"body": "bar",
"userId": 1
}
HTTP/1.1 201
jsonpath "$.title" == "foo"
2. Capturing Values
GET https://jsonplaceholder.typicode.com/posts/1
HTTP/1.1 200
[Captures]
jsonpath "$.userId" => user_id
You can then reuse {{user_id}}
in later requests.
3. Using Variables
You can pass variables from the CLI:
hurl test.hurl --variable name=John
And in your script:
GET https://example.com/hello?name={{name}}
β Running a Hurl Script
To run your .hurl
test:
hurl mytest.hurl
Add the --verbose
flag for detailed output:
hurl mytest.hurl --verbose
Or run multiple tests in a directory:
hurl tests/*.hurl
π§ͺ Test Automation Use Cases
Hurl is great for:
- Smoke testing APIs
- Validating HTTP endpoints in CI pipelines
- Replacing Postman collections with text-based tests
- Quick manual checks of services via terminal
π Debugging Tips
Use --verbose
or --very-verbose
for debugging HTTP headers and body
Use --insecure
for skipping SSL checks (e.g., for localhost testing)
Use environment variables and .env
files for secrets
π More Resources
-
Official site: https://hurl.dev
-
GitHub repo: https://github.com/Orange-OpenSource/hurl
-
Documentation: https://hurl.dev/docs