HTTPie client

Learn how to install and use HTTPie, a beginner-friendly command-line HTTP client for testing APIs with readable, colored output.

When you type a web address into a browser, the browser sends an HTTP request across the internet and shows you the answer. HTTPie does the same job from your terminal, except that it gives you control over every detail of the request. That makes it one of the most useful tools for testing an API before, during, and after you build it.

What HTTPie is

HTTPie is a command-line program for sending HTTP requests and viewing the responses. The command you type is http, and it works on macOS, Linux, and Windows. HTTP stands for Hypertext Transfer Protocol, the rules that web servers and clients use to exchange data. When you visit a website, your browser sends an HTTP GET request. When you submit a form, it usually sends an HTTP POST request. HTTPie lets you send those same requests by hand, with full control over the method, the URL, the data, and the headers.

It is often compared to curl, the other well-known command-line HTTP client. curl is extremely powerful and is the right tool for scripts and low-level debugging. But its syntax can be terse and hard to remember. HTTPie was designed around a different goal: a human should be able to type a request quickly, read the response comfortably, and remember the syntax tomorrow. Its output is colored and indented, JSON is detected and pretty-printed automatically, and the request itself reads close to plain English.

HTTPie versus curl:

curl is the better choice when you need to embed a request inside a shell script, pipe raw output into another program, or reproduce an exact curl command from someone else's documentation. HTTPie is the friendlier choice for interactive exploration, learning how an API behaves, and typing test commands you will actually remember. Both tools do the same core job; they just optimize for different situations.

The mental model is simple: your terminal becomes a small API client. You type a request in a readable form - "http POST this URL with these fields" - and HTTPie assembles the full HTTP request, sends it across the network, and presents the server's answer in a clean layout. You do not need to remember the exact order of low-level headers or manually escape every special character.

Installing HTTPie

The package you install is called httpie, but the command you will type is http. Most package managers handle the difference for you. Pick the tab for your operating system:

Homebrew is the standard package manager on macOS. Install HTTPie with:

brew install httpie

After installation, verify that the command is available:

http --version

You should see a version number such as 3.2.4. The exact number depends on when you installed the tool, and any recent version works for everything in this page.

Installation verified:

If a version number prints, HTTPie is ready to use. If your shell answers with "command not found", close the terminal and open a new one first - some shells only reload their search paths after restarting.

The installer also provides an https command. It forces the secure HTTPS protocol, while http handles both http:// and https:// URLs automatically. You can safely use http for all the examples here.

Running your first request

Before you test anything of your own, a free practice service called httpbin.org gives you a safe URL that echoes back whatever you send. It exists specifically for trying HTTP clients, and it is perfect for learning HTTPie. The examples in this page use httpbin.org as the target, but every command works unchanged against any other URL - including a local Axum server once one is running on http://localhost:3000.

Your first request is a single line:

http GET https://httpbin.org/get

This reads as: "send an HTTP GET request to https://httpbin.org/get". GET is the method browsers use when they ask a server to send information back. Because GET is HTTPie's default, this shorter form works identically:

http https://httpbin.org/get

When you run either command, HTTPie prints the response status line, the response headers, and the response body. Since httpbin returns JSON, HTTPie formats the body with indentation and color automatically. A trimmed version of the output looks like this:

HTTP/1.1 200 OK
Content-Type: application/json
{
    "args": {},
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Host": "httpbin.org",
        "User-Agent": "HTTPie/3.2.4"
    },
    "url": "https://httpbin.org/get"
}

The 200 OK on the first line is the status code: the server understood the request and succeeded. Inside the JSON body, the headers object is not the same thing as the response headers printed above the body. That headers object is httpbin's way of showing you which headers it received from you. Notice the User-Agent value - HTTPie identifies itself so a server knows which client is talking to it.

Your exact output will differ:

The Date header, your IP address, and the User-Agent version will vary by machine, network, and HTTPie version. The important thing is the overall shape: status line first, then headers, then a blank line, then the JSON body.

The request syntax

Every HTTPie command is built from the same four pieces, and learning them once unlocks every other feature:

http [flags] [METHOD] URL [REQUEST ITEMS]
  • flags are optional switches starting with one or two dashes, like --verbose or -v.
  • METHOD is the HTTP verb: GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS. If you omit it, HTTPie assumes GET.
  • URL is the destination, including the http:// or https:// part.
  • REQUEST ITEMS are optional pieces of data: query parameters, JSON fields, form fields, headers, or files. Each item uses a short operator character that tells HTTPie how to interpret it.

The four operators you will use constantly are:

OperatorMeaningExampleEffect
==Add a query parametername==AliceAppends ?name=Alice to the URL
=Add a string JSON or form fieldname=AliceSends the string "Alice"
:=Add a raw JSON valueage:=30Sends the number 30, not the string "30"
@Attach a file (use with --form)photo@cat.jpgUploads the file as multipart form data - only works together with --form; without it, HTTPie reports an error

Headers follow a separate rule: they are written as Header-Name:value with a single colon and no space immediately after the colon.

Adding query parameters

Query parameters are the key-value pairs that live in the URL itself, after a question mark. A search endpoint might expect ?q=rust&limit=10. In HTTPie, you add them with the == operator instead of building that part of the URL by hand:

http GET https://httpbin.org/get name==Alice age==30

The command above sends a request to this full URL:

https://httpbin.org/get?name=Alice&age=30

httpbin echoes the values back in the args object of the JSON response:

{
    "args": {
        "age": "30",
        "name": "Alice"
    },
    "url": "https://httpbin.org/get?name=Alice&age=30"
}

You can also write the query string directly into the URL if you prefer, but you must quote it so the shell does not interpret the & character as a "run this in the background" instruction:

http GET "https://httpbin.org/get?name=Alice&age=30"

The == operator form is easier to read once you have several parameters, and it avoids that shell escaping problem entirely.

One equals sign and two equals signs are different:

A single = sends data in the request body. A double == appends a query parameter to the URL. If you write name=Alice when you meant name==Alice, the data goes into the body instead of the URL - and for a GET request, most servers ignore the body completely. The server would receive no query parameter at all.

Sending JSON data

Most modern APIs, including the Axum server you will build, exchange data as JSON for POST, PUT, and PATCH requests. HTTPie makes JSON the default whenever the data you send looks like JSON.

Start with a simple POST request:

http POST https://httpbin.org/post name=Alice email=alice@example.com age:=30

Three things happen here. POST is the method for creating or submitting data. The = items become JSON strings, while the := item becomes a JSON number. HTTPie automatically adds the Content-Type: application/json header and sends this body:

{
    "name": "Alice",
    "email": "alice@example.com",
    "age": 30
}

The rule to remember is that = always treats the value as text. So age=30 would send the string "30", not the number 30. The := operator sends the value as raw JSON - meaning whatever valid JSON you type is used exactly as written. For booleans, arrays, and nested objects, use :=:

http POST https://httpbin.org/post name=Bob active:=true tags:='["rust", "axum"]'

The single quotes around the array are important. They tell the shell to pass the square brackets and double quotes through unchanged instead of trying to interpret them itself. HTTPie then parses that text as JSON and sends:

{
    "name": "Bob",
    "active": true,
    "tags": ["rust", "axum"]
}

httpbin's response includes a json field mirroring exactly what it received.

Sending a JSON file as the request body

When the payload is long or complex, typing the whole thing on one line becomes messy. HTTPie can read the entire request body from a file when you redirect it:

http POST https://httpbin.org/post < data.json

First prepare data.json:

{
    "name": "Axum User",
    "email": "user@example.com",
    "settings": {
        "theme": "dark",
        "notifications": true
    },
    "roles": ["reader", "writer"]
}

The < character tells the shell to feed the file's contents into the command as standard input. HTTPie detects the JSON, sends it as the body, and still adds the correct Content-Type: application/json header. The file can have any name; it does not need to be called data.json.

You can also embed a file's contents into a JSON field with the =@ operator:

http POST https://httpbin.org/post "bio=@bio.txt"

This sends "bio": "the contents of bio.txt" as a JSON string. It is handy when an API expects a long text field and you want to keep that text in a separate file.

JSON files must be strictly valid:

If the JSON file contains a trailing comma, a missing closing brace, or a comment, the request fails with a syntax error before anything reaches the network. JSON does not allow comments or trailing commas. When a JSON request fails unexpectedly, check the file for those two mistakes first.

Form data and file uploads

JSON is not the only way a server receives data. Traditional HTML forms send data in a format called URL-encoded form data, and file uploads use a related format called multipart. HTTPie switches to these when you ask it to.

URL-encoded forms

Use the --form flag, or its short form -f, to send a regular form body:

http --form POST https://httpbin.org/post username=alice password=secret

The body becomes username=alice&password=secret, which is exactly what an HTML login page would send. httpbin's response includes a form object showing the parsed values.

Uploading files

File uploads also use --form, but with the @ operator. The item is written as fieldname@path/to/file:

http --form POST https://httpbin.org/post "document@/home/user/report.txt"

The part before @ is the form field name the server expects to receive. The part after @ is the path to the local file. If the file does not exist, HTTPie reports an error before sending anything.

For a quick test, create a small file and upload it:

echo "hello from HTTPie" > hello.txt
http --form POST https://httpbin.org/post "message@hello.txt"

httpbin's response contains a files object showing the uploaded content so you can confirm the upload worked.

Request headers

Headers are the small notes attached to every request. They carry authentication tokens, describe the type of content being sent, identify the client, and pass custom flags from one system to another. In HTTPie, a header item is written as Header-Name:value with a single colon and no space immediately after the colon:

http GET https://httpbin.org/headers "Authorization: Bearer abc123" "X-Request-ID: 42"

This sends two custom headers: Authorization and X-Request-ID. httpbin's /headers endpoint responds with a headers object containing everything it received, so you can confirm the values arrived correctly.

A real API often requires an Authorization header for protected endpoints. You would write:

http GET https://api.example.com/private "Authorization: Bearer YOUR_TOKEN"

Replace the URL and token with the actual values for the API you are testing.

No space between the header name and the colon:

The colon must come immediately after the header name: Authorization:Bearer abc is correct, while Authorization : Bearer abc is not. When the value contains a space, wrap the entire item in double quotes, as in "Authorization: Bearer abc". Without quotes, the shell splits the item into separate arguments and HTTPie misreads the request.

Authentication

Most private APIs require proof of identity before they return data. Two schemes appear constantly: basic authentication and bearer tokens.

Basic authentication sends a username and password encoded in a header. HTTPie has a dedicated flag for it:

http -a alice:secret GET https://httpbin.org/basic-auth/alice/secret

The -a flag, also written --auth, takes username:password. httpbin's /basic-auth/alice/secret endpoint returns success only when the credentials match exactly, which makes it a good way to confirm the flag is working.

Bearer tokens are more common in modern APIs. There is no special flag because a bearer token is just a header:

http GET https://httpbin.org/bearer "Authorization: Bearer my-token-value"

httpbin's /bearer endpoint requires a bearer token in that header and reports whether it was present and correct.

A bearer token is just one header:

From HTTPie's perspective, bearer authentication is not a separate feature. It is a single header whose value starts with the word Bearer, a space, and then the token. Any client that can set headers can send bearer auth. The dedicated -a flag exists only for basic authentication.

Controlling the output

HTTPie's default output is a good middle ground, but sometimes you need more or less detail. The tool includes flags for every level of verbosity.

Print everything, including the outgoing request line and request headers, with verbose mode:

http -v GET https://httpbin.org/get

This shows the full request before the response, which is useful when you want to confirm exactly what was sent.

Print only the response body:

http --body GET https://httpbin.org/get

Print only the response headers:

http --headers GET https://httpbin.org/get

Preview a request without sending it at all - ideal for checking syntax before hitting a real server:

http --offline POST https://httpbin.org/post name=Alice age:=30

The --offline flag builds the complete request and prints it, but never opens a network connection.

Follow redirects automatically when a server responds with a "moved" status:

http --follow GET https://httpbin.org/redirect/1

Set a timeout so a slow or unresponsive server does not hang your terminal forever:

http --timeout=5 GET https://httpbin.org/delay/10

This abandons the request after 5 seconds even though the server would wait 10.

A few other flags worth knowing:

FlagWhat it does
-v / --verboseShow both the outgoing request and the response
--bodyShow only the response body
--headersShow only the response headers
--form / -fSend URL-encoded form data or multipart uploads
--json / -jForce the JSON content type even without obvious JSON data
--download / -dSave the response body to a file instead of printing it
--followFollow HTTP redirects automatically
--timeout=NGive up after N seconds
--offlineBuild and print the request without sending it
--check-statusExit with a non-zero status code when the response is a 4xx or 5xx error
--session=FILEStore and reuse headers across multiple requests

Reusing requests with sessions

A real API flow rarely consists of a single isolated request. You log in, receive a token or a cookie, and then send that same credential on every later request. HTTPie sessions exist to make that workflow painless. A session is just a JSON file on disk that stores response headers from one request and reattaches them to later ones.

1

Step 1: Create a session file

Use --session with a file path to record the first request:

http --session=/tmp/axum-session.json POST https://httpbin.org/post name=Alice

HTTPie writes the response headers to /tmp/axum-session.json.

2

Step 2: Make a second request with the same session

Point the next request at the same file:

http --session=/tmp/axum-session.json GET https://httpbin.org/get

Any stored cookies or authentication headers are now attached automatically.

3

Step 3: Inspect the session file

Open the JSON file to see what was stored:

cat /tmp/axum-session.json

You will see a structure containing cookies and headers. Keep this file private - it can hold credentials.

The /post and /get endpoints on httpbin do not set authentication cookies, so the session file will look fairly empty in this example. Against a real login endpoint, the story is different: the login response sets a session cookie, the session file captures it, and every later request using that session automatically sends the cookie along.

When you want to read from a session without changing it, use --session-read-only:

http --session-read-only=/tmp/axum-session.json GET https://httpbin.org/get

This attaches the stored headers but does not write any new ones back to the file.

Common mistakes and how to fix them

Several errors appear over and over for new HTTPie users. They are all avoidable once you know the patterns.

Using = where == is needed. A single equals sends a body field; a double equals adds a query parameter. If a server is not seeing your query string, check whether you accidentally used =.

Leaving a space between a header name and the colon. Authorization : Bearer abc is malformed. The colon must touch the header name, and any value containing spaces must be quoted as one item.

Sending := values that are not valid JSON. The := operator expects raw JSON on the right side. tags:=rust fails because rust is not valid JSON; the string form would be tags:='"rust"' and the array form would be tags:='["rust"]'.

Forgetting quotes around a URL containing &. The & character tells most shells to run the first part of the command in the background. Always quote a URL that contains &, or use the == operator to avoid putting & in the URL at all.

Swapping http and https by accident. A URL that starts with https:// must be reachable over TLS. If a server is only running locally without TLS, use http://localhost:PORT. Pay attention to which scheme the server actually listens on.

Pointing @ at a missing file. An upload item like photo@cat.jpg fails immediately if cat.jpg does not exist in the current directory. Check the path before running the command. It also fails if you forget --form - file uploads only work with --form, so http POST https://httpbin.org/post "photo@cat.jpg" on its own is an error.

None of these mistakes damage anything; they produce a failed request or an unexpected response. Reading the error message and the printed request with --verbose or --offline usually reveals the problem in seconds.

Summary

Every operator in this page maps to one specific part of an HTTP request: == goes into the URL, = and := go into the body as strings or raw JSON, @ attaches a file, and Header:value sets metadata. Once those mappings feel natural, nearly any API call is one short line in the terminal.

The choice between HTTPie and curl comes down to context, not capability. When you are exploring an endpoint interactively, diagnosing why a request behaves strangely, or writing a command you want to reread in a week, reach for HTTPie. When you are embedding a request in a script, piping raw output through other tools, or reproducing a snippet from someone else's documentation, curl is the more precise instrument.

What this page unlocks is a testing reflex. The moment an API is running on http://localhost:3000, these commands become the way you verify that a route exists, that a handler accepts the right JSON, that authentication rejects a bad token, and that error responses return the status codes you intended. The https://httpbin.org targets in the examples simply become http://localhost:3000 targets against your own server.