Back to Resources Resource

HTTPie - Human-Friendly HTTP Client

A modern alternative to curl with intuitive syntax, syntax-highlighted output, and sensible defaults. Making API testing a joy.

curl is powerful but cryptic. curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}'... HTTPie makes the same request as http POST api.example.com name=test. Human-readable syntax, colorized output, JSON by default.

🌈

API Testing Made Beautiful

Syntax-highlighted JSON, intuitive syntax, sessions for auth, and sensible defaults. The HTTP client that respects developers.

HTTPie in Action

See the difference between curl and HTTPie. Same request, dramatically better experience:

curl Traditional $ curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -H "Authorization: Bearer token123" \ -d '{"name":"John","email":"john@test.com"}' {"id":42,"name":"John","email":"john@test.com", "created_at":"2024-01-15T10:30:00Z","status": "active","role":"user"} No colors, no formatting, hard to read HTTPie Modern $ http POST api.example.com/users \ name=John email=john@test.com \ Authorization:"Bearer token123" HTTP/1.1 201 Created { "id":42, "name":"John", "status":"active" } HTTPie Features at a Glance { } JSON by Default Content-Type auto-set red green blue Syntax Highlighting Easy to scan responses key=value Intuitive Syntax No -d, no escaping 🔐 Session Support Persist auth & cookies GET request: http api.example.com/users That's it. No flags needed. Download file: http --download example.com/file.zip Progress bar included.

HTTPie provides colorized output, intuitive syntax, and sensible defaults compared to curl

Key Features

Intuitive Syntax

Natural language-like commands. http POST url key=value just works. No manual escaping.

🎨

Colorized Output

Syntax highlighting for JSON, headers, and status codes. Spot errors instantly.

📦

JSON by Default

Content-Type set automatically. Request bodies serialized to JSON. Response formatted nicely.

🔑

Sessions Support

Save auth tokens, cookies, and headers. Reuse across requests without repeating.

Practical Examples

Install HTTPie:

# Install on macOS
brew install httpie
# Install on Linux/pip
pip install httpie

Basic HTTP methods:

# GET request (method optional for GET)
http api.example.com/users
http GET api.example.com/users/42
# POST with JSON body (key=value for strings, key:=value for non-strings)
http POST api.example.com/users \
  name="John Doe" \
  email="john@example.com" \
  age:=30 \
  active:=true
# PUT to update
http PUT api.example.com/users/42 name="Jane Doe"
# DELETE
http DELETE api.example.com/users/42

Headers and authentication:

# Custom headers (use : for headers)
http api.example.com/data \
  Authorization:"Bearer eyJhbGciOiJIUzI1NiIs..." \
  X-Custom-Header:"some-value"
# Basic auth (shorthand)
http -a username:password api.example.com/protected
# Bearer token auth
http -A bearer -a token123 api.example.com/data

File operations:

# Upload file
http POST api.example.com/upload file@./photo.jpg
# Download file with progress
http --download example.com/large-file.zip

Why Developers Love It

  • No Memorization Required - Syntax is self-explanatory. key=value for data, Key:value for headers.
  • Readable Responses - Formatted JSON with syntax highlighting. No need to pipe through jq.
  • Sensible Defaults - JSON Content-Type, follow redirects, formatted output - all out of the box.
  • Session Persistence - Save auth cookies, reuse headers across requests with named sessions.
  • curl Compatible - Use --curl flag to generate equivalent curl commands.

Cheatsheet

curl vs HTTPie syntax comparison:

Task curl HTTPie
GET request curl https://api.com/data http api.com/data
POST JSON curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' http POST api.com key=val
Custom header curl -H "X-Token: abc" http api.com X-Token:abc
Basic auth curl -u user:pass http -a user:pass
File upload curl -F "file=@photo.jpg" http -f POST api.com file@photo.jpg
Download curl -O url/file.zip http --download url/file.zip
Follow redirects curl -L url http --follow url
Verbose curl -v url http --verbose url

Pro Tips

Advanced HTTPie features for power users:

🔐

Named Sessions

Save auth tokens and cookies to reuse across requests:

# Login and save session
http --session=myapi POST api.com/login user=me pass=secret

# Use session for subsequent requests
http --session=myapi api.com/protected
📋

Output Control

# Headers only
http --headers api.com/data

# Body only (for piping)
http --body api.com/data

# Both headers and body
http --print=hb api.com/data
🔄

Generate curl Commands

# Show equivalent curl command
http --curl POST api.com/users name=test

Perfect for sharing with teammates who use curl.

📝

JSON from File

# Send JSON file as body
http POST api.com/data < payload.json

# Or use stdin
echo '{"key":"value"}' | http POST api.com/data
🎯

Query Parameters

# Use == for query params
http api.com/search q==term page==1 limit==20

# Equivalent to: api.com/search?q=term&page=1&limit=20

Getting Started

  1. 1

    Install HTTPie

    Use brew install httpie on Mac or pip install httpie elsewhere.

  2. 2

    Make Your First Request

    Try http httpbin.org/get to see colorized JSON output.

  3. 3

    Test POST Requests

    Try http POST httpbin.org/post name=test to see JSON body handling.

  4. 4

    Explore More

    Run http --help or visit the docs for sessions, auth, and more.

Try HTTPie Now

Make API testing enjoyable. Intuitive syntax, beautiful output, sensible defaults.

Get HTTPie

Explore More Resources