Test Your HTTP APIs with Plain Text Files
As developers, we're constantly interacting with HTTP APIs. Whether we're building a client, testing a backend, or debugging a third-party integration, we need tools that are simple, effective, and fit into our workflow. While GUI tools like Postman or Insomnia are powerful, sometimes you just want to write a script, check it into version control, and run it from the command line.
That's where Hurl comes in. It's a command-line tool that lets you run HTTP requests defined in simple plain text files. It's like curl, but supercharged for testing and automation, and it's incredibly straightforward to use.
What It Does
Hurl takes a text file containing one or more HTTP requests and executes them. But it doesn't just stop at sending requests. Its real power is in its ability to assert things about the responses. You can check status codes, headers, and body content, and even chain requests together, using values from one response in the next request. It's a complete tool for testing and automating your API workflows.
The syntax is clean and human-readable. You define your requests in a format that will feel instantly familiar, almost like writing an HTTP request in an email.
Why It's Cool
The beauty of Hurl is in its simplicity and its power. Here’s what makes it stand out:
- Plain Text is King: Your "tests" or "request collections" are just text files (
.hurl
). This means they are trivial to version control, diff, and share with teammates. No more exporting and importing JSON collections from GUI apps. - It's a Testing Tool, Not Just a Request Sender: You can write strong assertions directly alongside your request. Want to ensure a
GET
request returns a 200 and a JSON body with a specific field? Hurl can do that with a simple, expressive syntax. - Chain Requests Easily: Need to authenticate and then use the token in a subsequent call? Hurl lets you capture values from headers or response bodies (using JSONPath or XPath) and inject them into the next request. This is essential for testing real-world flows.
- It's Fast and CLI-Native: It's built for the terminal. Integrate it into your shell scripts, CI/CD pipelines (hello, GitHub Actions!), and make it part of your development routine.
How to Try It
Getting started with Hurl is a breeze.
-
Install it: You can grab the binary for Windows, macOS, or Linux from the official GitHub releases page. It's also available via popular package managers:
# On macOS with Homebrew: brew install hurl # On Linux with Linuxbrew: brew install hurl
-
Create your first
.hurl
file. Let's call ittest-api.hurl
:GET https://api.example.com/status HTTP 200 [Asserts] jsonpath "$.status" == "OK" header "Content-Type" contains "json"
-
Run it from your terminal:
hurl test-api.hurl
That's it! Hurl will execute the request and report if all your asserts passed.
The GitHub repository has excellent documentation with tons of examples to show you all its capabilities, from posting JSON data to testing HTML content.
Final Thoughts
Hurl feels like a tool that gets developers. It solves a common problem—testing HTTP APIs—with a no-nonsense, scriptable approach. It won't replace the quick exploratory debugging you do in a browser's DevTools, but for writing repeatable, shareable tests and automation scripts, it's fantastic. If you live in the terminal and value simplicity and power, Hurl is absolutely worth adding to your toolkit. It might just become your go-to for API testing.
—
Follow us for more cool projects: @githubprojects