DEV Community

Piers Roberts
Piers Roberts

Posted on

hurl

Why I Use Hurl for HTTP API Testing

As a developer who often tests and experiments with APIs, I’m always on the lookout for simple yet powerful tools. Recently, I started using Hurl, and it’s quickly become one of my favorites for running and testing HTTP requests.

What I Like About Hurl

Hurl lets me write HTTP requests in plain text files, exactly how I would type them in a terminal or Postman, but with the added ability to automate sequences and handle variables. This means I can chain requests, grab OAuth tokens from one response, and use them in the next request — all without writing complicated scripts in another language.

It’s a command-line tool, which fits perfectly into my workflow and CI/CD pipelines. I appreciate that it’s lightweight, fast, and supports modern features like HTTP/2 and retries. The syntax is straightforward, so there’s almost no learning curve.

Some Quick Examples

Here’s a simple GET request I’ve used to fetch user data:

GET https://api.example.com/users
Accept: application/json

HTTP/1.1 200
[Asserts]
jsonpath "$.length()" > 0
Enter fullscreen mode Exit fullscreen mode

And here’s how I retrieve an OAuth token and use it in another request:

POST https://auth.example.com/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=YOUR_ID&client_secret=YOUR_SECRET

HTTP/1.1 200
jsonpath "$.access_token" != null
[Capture]
token = jsonpath("$.access_token")
Enter fullscreen mode Exit fullscreen mode
GET https://api.example.com/data
Authorization: Bearer {{token}}

HTTP/1.1 200
Enter fullscreen mode Exit fullscreen mode

How to Get Started

If you want to try it out, installing Hurl is easy with Homebrew:

brew install hurl
Enter fullscreen mode Exit fullscreen mode

For more details and documentation, check out the official site: https://hurl.dev/

Final Thoughts

Hurl has simplified my API testing and automation work dramatically. If you want a no-fuss, scriptable way to run HTTP requests and manage OAuth tokens, give it a try — it might just save you a lot of time.

Top comments (0)