HTTPie
User-friendly command-line HTTP client.
Official WebsiteFeatures
Intuitive SyntaxJSON SupportSyntax HighlightingPlugins
Installation
Homebrew
brew install httpieAPT (Debian/Ubuntu)
apt install httpiePacman (Arch)
pacman -S httpiepip
pip install httpieWhy use HTTPie?
HTTPie is designed with the concept of "HTTP client for humans" in mind. With more intuitive syntax than curl, you can efficiently develop and debug APIs.
Readable Output
Colorful output with syntax highlighting. Headers and body are beautifully formatted.
Intuitive Syntax
Just list key=value pairs after the URL. JSON is handled automatically.
Authentication Support
Supports multiple auth methods including Basic, Bearer Token, and OAuth.
Session Management
Save cookies and headers as sessions. Run consecutive API tests easily.
Installation
Installation
# macOS (Homebrew)
brew install httpie
# pip (Python)
pip install httpie
# Ubuntu/Debian
sudo apt install httpie
# Arch Linux
sudo pacman -S httpie
# Windows (pip)
pip install httpieBasic Usage
GET Request
GET
# Simple GET
http GET https://api.github.com/users/octocat
# http defaults to GET
http https://api.github.com/users/octocat
# Query parameters
http https://api.github.com/search/repositories q==python sort==stars
# Add headers
http https://api.example.com/data Accept:application/json X-API-Key:secret123POST Request
POST
# Send JSON data (default)
http POST https://api.example.com/users name=John age:=30 active:=true
# = is string, := is JSON value (number, boolean, array, object)
# Send array
http POST https://api.example.com/items tags:='["dev","test"]'
# Nested object
http POST https://api.example.com/users user[name]=John user[email]=john@example.comOther HTTP Methods
HTTP Methods
# PUT
http PUT https://api.example.com/users/1 name=Jane
# PATCH
http PATCH https://api.example.com/users/1 email=jane@example.com
# DELETE
http DELETE https://api.example.com/users/1
# HEAD (get headers only)
http HEAD https://api.example.com/healthCommon Patterns
Authentication
Authentication
# Basic auth
http -a username:password https://api.example.com/secure
# Bearer Token
http https://api.example.com/data Authorization:"Bearer your-token-here"
# API Key (header)
http https://api.example.com/data X-API-Key:your-api-key
# API Key (query parameter)
http https://api.example.com/data api_key==your-api-keyFile Upload
Upload
# Upload file (multipart/form-data)
http -f POST https://api.example.com/upload file@/path/to/image.jpg
# Multiple files
http -f POST https://api.example.com/upload files@image1.jpg files@image2.jpg
# Combine file with fields
http -f POST https://api.example.com/upload file@document.pdf description="Report"JSON Body
JSON Body
# JSON from standard input
echo '{"name":"John","age":30}' | http POST https://api.example.com/users
# JSON body from file
http POST https://api.example.com/users < user.json
# Here document
http POST https://api.example.com/users <<< '{"name":"John","items":[1,2,3]}'Advanced Usage
Sessions
Sessions
# Use session (save cookies)
http --session=mysession POST https://api.example.com/login username=user password=pass
# Subsequent requests with same session
http --session=mysession https://api.example.com/dashboard
# Named session (saved per host)
http --session=./session.json https://api.example.com/data
# Read-only session (don't save changes)
http --session-read-only=mysession https://api.example.com/profileOutput Control
Output Control
# Show headers only
http --headers https://api.example.com/data
# Show body only
http --body https://api.example.com/data
# Show both request and response
http --verbose https://api.example.com/data
# Download
http --download https://example.com/file.zip
# Save output to file
http https://api.example.com/data > response.jsonProxy and SSL
Proxy and SSL
# HTTP proxy
http --proxy=http:http://proxy.example.com:8080 https://api.example.com
# Skip SSL certificate verification (development only)
http --verify=no https://localhost:8443/api
# Client certificate
http --cert=client.pem --cert-key=client-key.pem https://api.example.comCommon Options
| Option | Description | Example |
|---|---|---|
-v, --verbose | Verbose output (including request) | http -v GET url |
-h, --headers | Show headers only | http -h GET url |
-b, --body | Show body only | http -b GET url |
-f, --form | Send as form data | http -f POST url file@f.txt |
-a | Basic authentication | http -a user:pass url |
--json, -j | JSON mode (explicit) | http -j POST url data=val |
--timeout | Timeout in seconds | http --timeout=30 url |
Comparison with curl
GET Request
Comparison: GET
# curl
curl -H "Accept: application/json" https://api.example.com/users
# HTTPie
http https://api.example.com/users Accept:application/jsonPOST Request (JSON)
Comparison: POST
# curl
curl -X POST -H "Content-Type: application/json" -d '{"name":"John","age":30}' https://api.example.com/users
# HTTPie
http POST https://api.example.com/users name=John age:=30Tips
- •
=is interpreted as string,:=is interpreted as JSON. Use:=for numbers and booleans - •
==adds query parameters (?key=value) - •When piping output to
jq, usehttp -bto output body only - •Customize default settings in
~/.config/httpie/config.json - •HTTPie Desktop (GUI version) is also available for more visual API testing