HTTPie: modern, user-friendly command-line HTTP client for the API era.
—
HTTPie's command-line interface provides three main commands for making HTTP requests and managing HTTPie functionality.
from httpie.status import ExitStatus
from httpie.cli.constants import *The primary http command for making HTTP requests with intuitive syntax.
http [METHOD] URL [REQUEST_ITEM ...]
# METHOD: HTTP method (GET, POST, PUT, DELETE, etc.) - defaults to GET
# URL: Request URL
# REQUEST_ITEM: Request items in key=value, key:=json, key@file formatsRequest Items:
key=value - Form fields or query parameterskey:=value - JSON data (value is parsed as JSON)key:=@file - JSON data from filekey@file - File uploadHeader:value - Custom HTTP headersUsage Examples:
# GET request
http httpie.io/hello
# POST with JSON data
http POST pie.dev/post name=John age:=30 active:=true
# Custom headers
http pie.dev/headers X-Custom-Header:value Authorization:"Bearer token"
# File upload
http --form POST pie.dev/post avatar@~/avatar.jpg
# Query parameters
http pie.dev/get search==httpie limit==10Identical to http but defaults to HTTPS protocol.
https [METHOD] URL [REQUEST_ITEM ...]The httpie command provides package and plugin management functionality.
httpie [COMMAND] [OPTIONS]
# Available commands:
# plugins - Plugin management
# sessions - Session management
# export - Export functionality--print=WHAT # Control output: H (headers), B (body), h (request headers), b (request body)
--headers, -h # Print only response headers
--body, -b # Print only response body
--verbose, -v # Verbose output
--quiet, -q # Quiet output--json, -j # Serialize data as JSON (default for non-form)
--form, -f # Serialize data as form (default for form data)
--pretty=FORMAT # Pretty-print format: all, colors, format, none
--style=STYLE # Output style (auto, solarized, etc.)
--auth=USER:PASS, -a # Authentication credentials
--auth-type=TYPE # Authentication type
--session=NAME # Session name for persistent data--timeout=SECONDS # Request timeout
--max-redirects=NUM # Maximum number of redirects
--follow, -F # Follow redirects
--check-status # Exit with error status for HTTP error codes
--verify=VERIFY # SSL certificate verification
--cert=FILE # SSL client certificate
--proxy=PROTOCOL:URL # Proxy configuration--download, -d # Download mode
--continue, -c # Resume partial download
--output=FILE, -o # Output file for download--offline # Build request without sending
--debug # Debug mode with detailed information
--traceback # Show full exception tracebackHTTPie returns different exit codes based on the request outcome:
# Success
0 # OK - request completed successfully
# General errors
1 # Error - general error (network, parsing, etc.)
2 # Timeout - request timed out
6 # Too many redirects
# HTTP status-based errors (when --check-status is used)
3 # HTTP 3xx (redirection)
4 # HTTP 4xx (client error)
5 # HTTP 5xx (server error)
# Special cases
7 # Plugin error
130 # Keyboard interrupt (Ctrl+C)HTTPie reads configuration from:
~/.config/httpie/config.json (Linux/macOS)~/.config/httpie/sessions/~/.config/httpie/plugins/Example config.json:
{
"default_options": [
"--style=solarized",
"--timeout=60"
]
}# Basic auth
http -a username:password httpie.io/basic-auth/username/password
# Bearer token
http pie.dev/bearer Authorization:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
# Custom auth plugin
http --auth-type=ntlm -a domain\\username:password example.com# Simple JSON
http POST pie.dev/post name=John age:=30
# Nested JSON
http POST pie.dev/post user[name]=John user[age]:=30
# JSON from file
http POST pie.dev/post @data.json
# Mixed data
http POST pie.dev/post name=John age:=30 token:=@token.txt# Single file upload
http --form POST pie.dev/post file@document.pdf
# Multiple files
http --form POST pie.dev/post file1@image.jpg file2@document.pdf
# File with metadata
http --form POST pie.dev/post file@image.jpg description="Profile photo"# Create session with login
http --session=user1 -a john:password pie.dev/basic-auth/john/password
# Use session for subsequent requests
http --session=user1 pie.dev/user/profile
# Session persists cookies, auth, and custom headers
http --session=user1 pie.dev/api/data X-Custom-Header:valueInstall with Tessl CLI
npx tessl i tessl/pypi-httpie