Httpie is a command-line HTTP client with human-readable syntax and colored output, designed for testing APIs from the terminal. The tool uses intuitive syntax: http GET https://api.example.com/users without the need to specify flags for headers and the request body. According to Httpie CLI Documentation (2026), the utility supports JSON by default, sessions, authentication, and plugins.
Key Points
Httpie (or HTTPie) is a command-line utility written in Python that simplifies sending HTTP requests compared to cURL. The main difference is syntax close to natural language: arguments are separated by spaces, headers are specified with a colon, and JSON data is specified with an equals sign without escaping quotes.
The same POST request in cURL requires at least three flags (-X, -H, -d) and manual JSON escaping. Httpie does the same in three words without flags, automatically setting Content-Type: application/json and highlighting the output. The response is formatted with indentation and syntax highlighting by default.
| Operation | cURL | Httpie |
|---|---|---|
| GET request | curl https://api.example.com | http GET https://api.example.com |
| POST JSON | curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://api.example.com | http POST https://api.example.com name=test |
| Header | curl -H "Authorization: Bearer token123" https://api.example.com | http GET https://api.example.com Authorization:"Bearer token123" |
Httpie uses a single command-line format without flags for the main parameters. The HTTP method is specified as the first argument (GET, POST, PUT, DELETE, PATCH), the URL as the second. If the method is omitted, Httpie automatically chooses GET (for requests without a body) or POST (with a body).
Authorization:"Bearer token".name=John age=30.active:=true tags:=["dev","test"].avatar@~/photo.jpg.Httpie automatically determines the data type: if key=value is passed, the body is sent as JSON. If raw text is passed via --raw, it is sent as plain text. The form-data format is activated with the -f flag.
# POST request with JSON data and a header
http POST https://api.example.com/users \
name="John Doe" \
email="john@example.com" \
role:="admin" \
Authorization:"Bearer test123"
# Response with highlighting and pretty-print
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": 42,
"name": "John Doe"
}
JSON serialization in Httpie works automatically: a value passed as key=value becomes a string field of the JSON. For numbers and boolean values, key:=value is used. Nested objects are created using dot notation: address.city=Moscow.
Httpie supports the multipart/form-data format for uploading files and data via the key@path syntax. If you need to send the file contents as the raw request body, input redirection is used: http POST example.com < file.json. To download the response to a file, the -d (download) flag is used.
# Sending JSON from a file
http POST https://api.example.com/users < user.json
# Uploading a file via multipart
http -f POST https://api.example.com/upload \
photo@~/photo.jpg \
description="Profile photo"
Sessions in Httpie preserve state between requests: cookies, headers, and authentication parameters. A session is created with the --session=name flag. Session data is stored in a JSON file in the ~/.httpie/sessions/ folder. A session with the :readonly suffix is not updated after a request.
First, a POST request to /auth/login is made with credentials — the server returns a session cookie. All subsequent requests to protected endpoints within the same session automatically send the saved cookie, which simulates browser behavior when testing the API of a mobile app.
# Step 1: authentication
http --session=app-test POST https://api.example.com/auth/login \
username="dev" password="secret"
# Step 2: request with the saved session cookie
http --session=app-test GET https://api.example.com/users/me
Httpie supports all the main authentication types via flags: -a user:pass for Basic Auth, --auth-type=digest for Digest, --auth-type=bearer TOKEN for Bearer Token. Custom headers are added as HeaderName:value anywhere in the command.
For testing an API with OAuth 2.0, the token is passed via the Authorization header. Httpie does not manage the token lifecycle at the core level — an external script does this. The command http --auth-type=bearer --auth="$TOKEN" GET https://api.example.com/resource is equivalent to explicitly specifying the header with the token.
Httpie is ideal for CI/CD pipelines thanks to zero dependencies (except Python) and readable output. Commands are easy to read in logs without additional parsing. The tool is installed via pip and is available in all popular Docker images, including Alpine, Ubuntu, and the official CI images of Jenkins and GitLab. This makes Httpie a convenient choice for automated testing of REST APIs and microservices.
A typical scenario is checking the API status after deploying an application. Httpie sends a request to the health endpoint and exits with a non-zero code if the response does not match the expected one. The --check-status flag automatically returns an error for status codes >= 300.
# Health check in the deploy script
http --check-status GET https://api.staging.example.com/health
status:="ok" && \
echo "API is healthy" || \
echo "API check failed"
Httpie supports plugins through the Package Index system. Plugins add new authentication types, serialization formats, and transports. Installation is done via pip: pip install httpie-plugin-name. After installation, the plugin is automatically activated at the next Httpie launch.
Httpie supports jq-like filtering via the --pretty=format option and cURL-compatible output via --print. The --quiet flag disables colored output for better readability in CI logs. For programmatic response processing, use the --body flag, which outputs only the response body without headers.
# Extracting a field from a JSON response with jq
http GET https://api.example.com/users/1 | jq '.name'
# Output only the response body (without headers)
http --body GET https://api.example.com/health
# Batch sending with different data from a file
while read -r line; do
http POST https://api.example.com/items $line
done < items.txt
Httpie supports output formats via the --print flag: H (request headers), B (request body), h (response headers), b (response body). The --print=hb combination outputs only the response headers and body. The --pretty=all flag enables colored formatting with indentation.
Httpie supports customization via the HTTPIE_COLORS variable. Configure colors for URL, headers, JSON, and status codes. Built-in themes are available: autumn, borland, fruity, monokai, native, tango for different terminals.
For programmatic processing, use --body --pretty=none, which returns raw JSON. Compact output is useful for passing to jq, sed, and other parsers when automating API testing in scripts.
Httpie supports several output formats via the --print flag: H (request headers), B (request body), h (response headers), b (response body). The --print=hb combination outputs only the response headers and body, excluding connection meta-information. The --pretty=all flag enables colored formatting with indentation for readability.
Httpie supports color customization via the HTTPIE_COLORS environment variable. You can configure colors for URL, headers, JSON keys, and response status codes. Built-in themes are available: autumn, borland, fruity, monokai, native, and tango for different terminal types and personal preferences.
For programmatic output processing, use the --body --pretty=none flag combination, which returns raw JSON without colors and indentation. Compact output is useful for passing to jq, sed, and other console parsers when automating REST API testing in shell scripts.
Frequently Asked Questions
Httpie offers more readable syntax without flags for basic operations, automatic JSON serialization, colored response highlighting, and built-in session support. cURL remains indispensable for low-level operations: working with FTP, SMTP, and non-standard protocols.
Use the -f flag (or --form): http -f POST example.com name=John file@~/photo.jpg. Httpie will automatically set Content-Type: multipart/form-data. Without the -f flag, data is sent as application/json.
Yes, Httpie supports HTTPS. For self-signed certificates, use the --verify=no flag. To specify a custom CA file: --verify=/path/to/cert.pem. Certificate verification is enabled by default.
No, Httpie does not support WebSocket and is intended exclusively for the HTTP/HTTPS protocol. For WebSocket, use websocat or wscat. Httpie focuses on REST, GraphQL, and file operations.
Use the -d (download) flag: http -d GET https://example.com/file.zip. Httpie will save the file with the original name from the Content-Disposition header or URL. For a custom name, specify -o output.zip.
Summary
http [method] URL [key=value] [Header:value] requires no flags for most requests.We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also