http(1)

πŸ“¦
version 3.2.4 Β· 4 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

http β€” okay bestie, this is the one, the icon, the main character πŸ’…

This is the manual page for http(1), and honestly? It's giving legend behaviour. Sit down, grab a boba, we're doing this. πŸ§‹


✨ SYNOPSIS ✨

http [METHOD] URL [REQUEST_ITEM ...]

That's it. That's the whole vibe. 🫢


πŸ’– DESCRIPTION πŸ’–

HTTPie: modern, user-friendly command-line HTTP client for the API era. ✨

<https://httpie.io>

No cap, it's the prettiest way to talk to an API from your terminal. πŸ’…


πŸŽ€ POSITIONAL ARGUMENTS πŸŽ€

So these little cuties come after any flags, and in the exact order they're listed here. Only URL is required β€” everything else is optional, like your third coffee of the day. β˜•

  • METHOD β€” the HTTP method for the request (GET, POST, PUT, DELETE, ...). You can literally just skip it, and HTTPie will use POST if there's some data to send, otherwise GET:
$ http example.org               # => GET
$ http example.org hello=world   # => POST
  • URL β€” the request URL. If your URL doesn't have a scheme, it defaults to 'http://'. (You can override this with: --default-scheme=http/https)

There's also a lil shorthand for localhost, and it ate:

$ http :3000                    # => http://localhost:3000
$ http :/foo                    # => http://localhost/foo
  • REQUEST_ITEM β€” optional key-value pairs to include in the request. The separator you use decides the type, so pay attention bestie:

':' HTTP headers:

Referer:https://httpie.io  Cookie:foo=bar  User-Agent:bacon/1.0

'==' URL parameters, appended to the request URI:

search==httpie

'=' Data fields, serialized into a JSON object (with --json, -j) or form data (with --form, -f):

name=HTTPie  language=Python  description='CLI HTTP client'

':=' Non-string JSON data fields (only with --json, -j):

awesome:=true  amount:=42  colors:='["red", "green", "blue"]'

'@' Form file fields (only with --form or --multipart):

cv@~/Documents/CV.pdf
cv@'~/Documents/CV.pdf;type=application/pdf'

'=@' A data field like '=', but it takes a file path and embeds its content:

essay=@Documents/essay.txt

':=@' A raw JSON field like ':=', but it takes a file path and embeds its content:

package:=@./package.json

And if a separator is colliding with your field name? Escape it with a backslash, bestie:

field-name-with\:colon=value

πŸ¦‹ PREDEFINED CONTENT TYPES πŸ¦‹

  • --json, -j β€” (this is the default, btw) Data items from the command line get serialized as a JSON object. The Content-Type and Accept headers are set to application/json (if not specified).
  • --form, -f β€” Data items from the command line get serialized as form fields. The Content-Type is set to application/x-www-form-urlencoded (if not specified). And the presence of any file fields results in a multipart/form-data request. πŸ’«
  • --multipart β€” Similar to --form, but it always sends a multipart/form-data request (i.e., even without files). Periodt.
  • --boundary β€” Specify a custom boundary string for multipart/form-data requests. Only has effect together with --form.
  • --raw β€” This lets you pass raw request data without extra processing (as opposed to the structured request items syntax):
$ http --raw='data' pie.dev/post

You can achieve the same thing by piping the data via stdin:

$ echo data | http pie.dev/post

Or have HTTPie load the raw data from a file:

$ http pie.dev/post @data.txt

πŸ”₯ CONTENT PROCESSING OPTIONS πŸ”₯

  • --compress, -x β€” Content gets compressed (encoded) with the Deflate algorithm. The Content-Encoding header is set to deflate. Compression is skipped if it appears that the compression ratio is negative. Compression can be forced by repeating the argument. πŸ’ͺ

πŸ’… OUTPUT PROCESSING πŸ’…

  • --pretty β€” Controls output processing. The value can be "none" to not prettify the output (default for redirected output), "all" to apply both colors and formatting (default for terminal output), "colors", or "format".
  • --style, -s STYLE β€” Output coloring style (default is "auto"). It can be one of:
auto, pie, pie-dark, pie-light, solarized

For finding out all available styles on your system, try:

$ http --style

The "auto" style follows your terminal's ANSI color styles. For non-auto styles to work properly, please make sure the $TERM environment variable is set to "xterm-256color" or similar (e.g., via export TERM=xterm-256color in your ~/.bashrc). 🎨

  • --unsorted β€” Disables all sorting while formatting output. It's a shortcut for:
--format-options=headers.sort:false,json.sort_keys:false
  • --sorted β€” Re-enables all sorting options while formatting output. It's a shortcut for:
--format-options=headers.sort:true,json.sort_keys:true
  • --response-charset ENCODING β€” Override the response encoding for terminal display purposes, e.g.:
--response-charset=utf8
--response-charset=big5
  • --response-mime MIME_TYPE β€” Override the response mime type for coloring and formatting for the terminal, e.g.:
--response-mime=application/json
--response-mime=text/xml
  • --format-options β€” Controls output formatting. Only relevant when formatting is enabled through (explicit or implied) --pretty=all or --pretty=format. The following are the default options:
headers.sort:true
json.format:true
json.indent:4
json.sort_keys:true
xml.format:true
xml.indent:2

You may use this option multiple times, and also specify multiple comma-separated options at the same time. For example, this modifies the settings to disable the sorting of JSON keys, and sets the indent size to 2:

--format-options json.sort_keys:false,json.indent:2

This is something you will typically put into your config file. πŸ—‚οΈ


🌈 OUTPUT OPTIONS 🌈

  • --print, -p WHAT β€” A string specifying what the output should contain:
'H' request headers
'B' request body
'h' response headers
'b' response body
'm' response metadata

The default behaviour is 'hb' (i.e., the response headers and body get printed), if standard output is not redirected. But if the output is piped to another program or to a file, then only the response body is printed by default.

  • --headers, -h β€” Print only the response headers. Shortcut for --print=h.
  • --meta, -m β€” Print only the response metadata. Shortcut for --print=m.
  • --body, -b β€” Print only the response body. Shortcut for --print=b.
  • --verbose, -v β€” Verbose output, we love a chatty king πŸ‘‘. For level one (with a single -v/--verbose), print the whole request as well as the response. Also print any intermediary requests/responses (such as redirects). For the second level and higher, print these as well as the response metadata.

Level one is a shortcut for: --all --print=BHbh Level two is a shortcut for: --all --print=BHbhm

  • --all β€” By default, only the final request/response is shown. Use this flag to show any intermediary requests/responses as well. Intermediary requests include followed redirects (with --follow), the first unauthorized request when Digest auth is used (--auth=digest), etc.
  • --stream, -S β€” Always stream the response body by line, i.e., behave like tail -f.

Without --stream and with --pretty (either set or implied), HTTPie fetches the whole response before it outputs the processed data.

Set this option when you want to continuously display a prettified long-lived response, such as one from the Twitter streaming API. 🐦

It's useful also without --pretty: it ensures that the output is flushed more often and in smaller chunks.

  • --output, -o FILE β€” Save output to FILE instead of stdout. If --download is also set, then only the response body is saved to FILE. Other parts of the HTTP exchange are printed to stderr.
  • --download, -d β€” Do not print the response body to stdout. Rather, download it and store it in a file. The filename is guessed unless specified with --output [filename]. This action is similar to the default behaviour of wget.
  • --continue, -c β€” Resume an interrupted download. Note that the --output option needs to be specified as well.
  • --quiet, -q β€” Do not print to stdout or stderr, except for errors and warnings when provided once. Provide it twice to suppress warnings as well. stdout is still redirected if --output is specified. This flag doesn't affect the behaviour of download beyond not printing to terminal. 🀫

πŸ“ SESSIONS πŸ“

  • --session SESSION_NAME_OR_PATH β€” Create, or reuse and update a session. Within a session, custom headers, auth credential, as well as any cookies sent by the server persist between requests. πŸ”

Session files are stored in:

[HTTPIE_CONFIG_DIR]/<HOST>/<SESSION_NAME>.json.

See the following page to find out your default HTTPIE_CONFIG_DIR:

https://httpie.io/docs/cli/config-file-directory
  • --session-read-only SESSION_NAME_OR_PATH β€” Create or read a session without updating it from the request/response exchange. Just vibes, no writes. 🧊

πŸ‘‘ AUTHENTICATION πŸ‘‘

  • --auth, -a USER[:PASS] | TOKEN β€” For username/password based authentication mechanisms (e.g. basic auth or digest auth), if only the username is provided (-a username), HTTPie will prompt for the password. πŸ”
  • --auth-type, -A β€” The authentication mechanism to be used. Defaults to "basic".

"basic": Basic HTTP auth

"digest": Digest HTTP auth

"bearer": Bearer HTTP Auth

To see all available auth types on your system, including ones installed via plugins, run:

$ http --auth-type
  • --ignore-netrc β€” Ignore credentials from .netrc. πŸ™ˆ

🌐 Network

okay so this is where we tell httpie how to actually go outside and talk to the internet, and bestie, there are SO many knobs. let's go. πŸ’…

  • --offline β€” builds the request and prints it out like a little show-and-tell, but does NOT actually send it. zero network. all vibes, no delivery. 🫢
  • --proxy PROTOCOL:PROXY_URL β€” a string that maps a protocol to the URL of a proxy, like http:http://foo.bar:3128. you can stack up multiple proxies for different protocols, no problem. and the environment variables $ALL_PROXY, $HTTP_PROXY, and $HTTPS_proxy are supported too, so you can just set it and forget it. ✨
  • --follow, -F β€” follow those 30x Location redirects. go where the server points you. πŸ¦‹
  • --max-redirects β€” by default requests cap out at 30 redirects (and yeah, this one works with --follow). so it's not infinite, thank god.
  • --max-headers β€” the maximum number of response headers to read before giving up. the default is 0, which means no limit at all. go off, read every single one. πŸ’€
  • --timeout SECONDS β€” the connection timeout of the request, in seconds. default value is 0, i.e. there's literally no timeout limit. IMPORTANT: this is not a time limit on the entire response download. it's more like β€” an error gets reported if the server hasn't issued a response for timeout seconds (and to be precise, if no bytes have been received on the underlying socket for timeout seconds). so it's a "hey are you alive" check, not a "hurry up and finish" check. 😭
  • --check-status β€” by default, HTTPie exits with 0 when no network or other fatal errors occur, period. this flag makes it also check the HTTP status code and exit with an error if the status is giving error. here's the tea:
    • server replies with a 4xx (Client Error) or 5xx (Server Error) β†’ HTTPie exits with 4 or 5 respectively.
    • response is a 3xx (Redirect) and --follow hasn't been set β†’ exit status is 3.
    • also, an error message gets written to stderr if stdout is redirected. πŸ“
  • --path-as-is β€” bypass the dot segment (/../ or /./) URL squashing. sometimes you just want your path to stay exactly how you wrote it. iconic.
  • --chunked β€” enable streaming via chunked transfer encoding. the Transfer-Encoding header gets set to chunked. stream it, bestie. πŸ”₯

πŸ”’ SSL

the security section, aka where we keep your certs safe and sound. πŸŽ€

  • --verify β€” set it to "no" (or "false") to skip checking the host's SSL certificate. defaults to "yes" ("true"). you can also pass the path to a CA_BUNDLE file for private certs. (or you can set the REQUESTS_CA_BUNDLE environment variable instead β€” same energy, different outfit. πŸ’…)
  • --ssl β€” the desired protocol version to use. this defaults to SSL v2.3, which will negotiate the highest protocol that both the server and your installation of OpenSSL support. heads up: the available protocols may vary depending on your OpenSSL installation (only the supported ones are shown here). 🌈
  • --ciphers β€” a string in the OpenSSL cipher list format.

see http --help for the default ciphers list on you system.

  • --cert β€” you can specify a local cert to use as a client side SSL certificate. this file may either contain both the private key and the certificate, or you may specify --cert-key separately. your call, queen. πŸ‘‘
  • --cert-key β€” the private key to use with SSL. only needed if --cert is given and the certificate file doesn't contain the private key.
  • --cert-key-pass β€” the passphrase to be used to with the given private key. only needed if --cert-key is given and the key file requires a passphrase. if you don't provide it, you'll be prompted interactively. πŸ™ˆ

πŸ› οΈ Troubleshooting

when things are Not Behaving, this is your group chat of last resorts.

  • --ignore-stdin, -I β€” do not attempt to read stdin. hands off the keyboard input. 🚫
  • --help β€” show this help message and exit. the classic.
  • --manual β€” show the full manual. that's... this! hi bestie!! 🫢
  • --version β€” show version and exit.
  • --traceback β€” prints the exception traceback should one occur. all the gory details.
  • --default-scheme β€” the default scheme to use if not specified in the URL.
  • --debug β€” prints the exception traceback should one occur, as well as other information useful for debugging HTTPie itself and for reporting bugs. the full deep-dive. πŸ’€

πŸ‘€ SEE ALSO

  • for every --OPTION there is also a --no-OPTION that reverts OPTION to its default value. so like, the undo button for every single flag. love that for us. πŸ’–
  • suggestions and bug reports are greatly appreciated:
https://github.com/httpie/cli/issues

and that's the whole thing, bestie!! πŸŽ‰ this page is from HTTPie 3.2.4, dated 2024-07-10, and it lives in section http(1) of the manual. go forth and make some requests, you absolute icon. periodt. πŸ’…βœ¨πŸŒˆ