LinuxCommandLibrary

http

Send HTTP requests from the command line

TLDR

Make a simple GET request (shows response headers and content)

$ http [https://example.com]
copy

Print specific parts of the content (H: request headers, B: request body, h: response headers, b: response body, m: response metadata)
$ http [[-p|--print]] [H|B|h|b|m|Hh|Hhb|...] [https://example.com]
copy

Specify the HTTP method when sending a request and use a proxy to intercept the request
$ http [GET|POST|HEAD|PUT|PATCH|DELETE|...] --proxy [http|https]:[http://localhost:8080|socks5://localhost:9050|...] [https://example.com]
copy

Follow any 3xx redirects and specify additional headers in a request
$ http [[-F|--follow]] [https://example.com] ['User-Agent: Mozilla/5.0' 'Accept-Encoding: gzip']
copy

Authenticate to a server using different authentication methods
$ http [[-a|--auth]] [username:password|token] [[-A|--auth-type]] [basic|digest|bearer] [GET|POST|...] [https://example.com/auth]
copy

Construct a request but do not send it (similar to a dry-run)
$ http --offline [GET|DELETE|...] [https://example.com]
copy

Use named sessions for persistent custom headers, auth credentials and cookies
$ http --session [session_name|path/to/session.json] [[-a|--auth]] [username]:[password] [https://example.com/auth] [API-KEY:xxx]
copy

Upload a file to a form (the example below assumes that the form field is )
$ http [[-f|--form]] [POST] [https://example.com/upload] [cv@path/to/file]
copy

SYNOPSIS

http [OPTIONS]... URL [KEY=VALUE [KEY=VALUE...]]

PARAMETERS

-v, --verbose
    Print verbose request/response details.

-q, --quiet
    Silence httpie output; headers sent to stderr.

-j, --json
    Send data as JSON (default if data detected).

-f, --form
    Send form-encoded data.

-d, --download
    Download files; auto-detects filename.

-o FILE, --output FILE
    Save response body to FILE.

--print [H]B[h][j]
    Specify output: H=headers, B=body, h=status, j=JSON.

-a USER:PASS, --auth USER:PASS
    Use Basic authentication.

--session SESSION
    Load/save cookies/auth to session file.

-X METHOD
    Request method (GET, POST, PUT, etc.).

-h, --help
    Show help.

--version
    Show version.

DESCRIPTION

The http command, part of the httpie tool, is a cURL-like utility designed for painless HTTP testing and troubleshooting. Unlike traditional tools like curl, it offers a simple, intuitive syntax with features like colorized JSON output, automatic JSON detection, and progress bars. It simplifies API interactions by allowing key=value pairs for headers, data, and parameters directly after the URL.

Key strengths include human-readable output, session support for cookies/auth, support for forms, file uploads, and plugins. It's ideal for developers testing REST APIs, debugging webhooks, or scripting HTTP requests. Install via pip (pip install httpie) or package managers. Output can be formatted as JSON, XML, or plain text, with options for verbose logging and offline mode simulation.

CAVEATS

Not installed by default; requires httpie package. Sensitive data like passwords visible in verbose output or process lists. Large downloads may consume memory without --stream.

BASIC USAGE EXAMPLES

GET request: http example.com
POST JSON: http POST pie.dev/post data='{"key":"val"}'
With headers: http example.com Accept:application/json X-API-Key:123

PLUGIN ECOSYSTEM

Extensible via plugins for OAuth, AWS auth, etc. See httpie.io/plugins.

HISTORY

Developed by Jakub Roztočil in 2011 as a friendly cURL alternative. First release 0.1 in 2012; now at v3.x with HTTP/2, plugins, and OAuth support. Widely used in DevOps and API testing.

SEE ALSO

curl(1), wget(1), lynx(1)

Copied to clipboard