https(1)

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

✨ https(1) β€” HTTPie Manual ✨

okay bestie, sit down, hydrate, because we're about to make you genuinely dangerous with the command line. this is https, from the HTTPie manual. πŸ’…


🌸 NAME 🌸

https

like, that's it, that's the whole name. iconic behaviour, no notes.


πŸ¦‹ SYNOPSIS πŸ¦‹

https [METHOD] URL [REQUEST_ITEM ...]

πŸ’– DESCRIPTION πŸ’–

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

<https://httpie.io>

that's the official one-liner and honestly? it ate. it's giving "curl but it actually respects you as a person."


πŸŽ€ Positional arguments πŸŽ€

okay so these come after any flags, and in the exact order they're listed here. and listen β€” only URL is required. everything else is a lil bonus. ✨

  • METHOD β€” the HTTP method for the request (GET, POST, PUT, DELETE, ...).

you can literally just not provide it, and HTTPie will figure it out: it uses 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 include a scheme, it defaults to http://. (and yes you can override that with --default-scheme=http/https)

also there's a lil shorthand for localhost, because typing localhost is so much work:

$ 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 what type of thing it is. this is the part that lowkey unlocks everything:
    • ':' β€” HTTP headers:
Referer:https://httpie.io  Cookie:foo=bar  User-Agent:bacon/1.0
  • '==' β€” URL parameters to be appended to the request URI:
search==httpie
  • '=' β€” data fields to be 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 something in your field name, you escape it with a backslash:

field-name-with\:colon=value

🌈 Predefined content types 🌈

  • --json, -j β€” this is the default, bestie. 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 heads up: 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).
  • --boundary β€” specify a custom boundary string for multipart/form-data requests. only has effect only together with --form. (yes, "only has effect only" β€” that's what it says, we don't question the lore)
  • --raw β€” this option lets you pass raw request data without any extra processing (as opposed to the structured request items syntax):
$ http --raw='data' pie.dev/post

you can get the same result by piping the data via stdin:

$ echo data | http pie.dev/post

or you can have HTTPie load the raw data from a file:

$ http pie.dev/post @data.txt

πŸ’œ Content processing options πŸ’œ

  • --compress, -x β€” content 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. and if you really want it, you can force compression by repeating the argument. periodt.


πŸ“ 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 in 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 that the $TERM environment variable is set to "xterm-256color" or similar (e.g., via export TERM=xterm-256color in your ~/.bashrc). do this or your colors will look cursed, no cap.

  • --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. these 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, as well as 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. iykyk. πŸ’…


🫢 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 is printed), if standard output is not redirected. 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. for the level one (with 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 is 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 twice to suppress warnings as well. stdout is still redirected if --output is specified. flag doesn't affect 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. yes, it remembers things for you. main character energy.

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 form the request/response exchange. (yes, "form" β€” we're quoting the original, don't @ us πŸ™ˆ)

πŸ‘‘ 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. cute, secure, thoughtful.
  • --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.

bestie. that's only part 1 of this saga. more is coming, don't go anywhere πŸ’–

🌐 NETWORK 🌐

  • --offline β€” builds the whole request and prints it out for you, but does NOT actually send it anywhere. window shopping, basically πŸ’…
  • --proxy PROTOCOL:PROXY_URL β€” a string that maps a protocol to the URL of the proxy (like http:http://foo.bar:3128). you can stack multiple proxies for different protocols, no problem. and yes, the environment variables $ALL_PROXY, $HTTP_PROXY, and $HTTPS_proxy are supported too 🫢
  • --follow, -F β€” follow those 30x Location redirects, bestie. chase the link, don't just stare at it πŸ¦‹
  • --max-redirects β€” by default requests cap out at 30 redirects (this one works together with --follow).
  • --max-headers β€” the max number of response headers to read before it gives up (default 0, which means no limit at all).
  • --timeout SECONDS β€” the connection timeout of the request, in seconds. default is 0, i.e. no timeout limit whatsoever. important tho: 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 (more precisely, if no bytes have been received on the underlying socket for timeout seconds). so it's the silent-treatment detector ✨
  • --check-status β€” okay so by default HTTPie exits with 0 when no network or other fatal errors happen. this flag tells it to ALSO check the HTTP status code and exit with an error if the status is giving error.

when the server replies with a 4xx (Client Error) or 5xx (Server Error) status code, HTTPie exits with 4 or 5 respectively. and if the response is a 3xx (Redirect) and --follow hasn't been set, then the exit status is 3. also, an error message gets written to stderr if stdout is redirected. πŸ‘‘

  • --path-as-is β€” bypass that dot segment (/../ or /./) URL squashing. no squashing today, the path stays exactly as you typed it πŸ™ˆ
  • --chunked β€” turns on streaming via chunked transfer encoding. the Transfer-Encoding header gets set to chunked. iconic behavior 🌈

πŸ”’ SSL πŸ”’

  • --verify β€” set it to "no" (or "false") to skip checking the host's SSL certificate. defaults to "yes" ("true"). you can also hand it the path to a CA_BUNDLE file for private certs. (or alternatively, set the REQUESTS_CA_BUNDLE environment variable instead.) ⭐
  • --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 get 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 can specify --cert-key separately.
  • --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 use 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. no cap πŸŽ€

πŸ› οΈ TROUBLESHOOTING πŸ› οΈ

  • --ignore-stdin, -I β€” do not attempt to read stdin. minding its own business fr fr πŸ’€
  • --help β€” show this help message and exit.
  • --manual β€” show the full manual. (yes, the whole thing, the big one πŸ“–)
  • --version β€” show version and exit.
  • --traceback β€” prints the exception traceback should one occur.
  • --default-scheme β€” the default scheme to use if it's not specified in the URL.
  • --debug β€” prints the exception traceback should one occur, plus other info that's useful for debugging HTTPie itself and for reporting bugs. the full detective mode πŸ”

πŸ‘€ SEE ALSO πŸ‘€

for every --OPTION there is also a --no-OPTION that reverts OPTION back to its default value. symmetry, we love to see it πŸ’–

suggestions and bug reports are greatly appreciated:

https://github.com/httpie/cli/issues

and that's the whole page, bestie!! πŸŽ€βœ¨ this was HTTPie 3.2.4 from 2024-07-10, filed under https(1) β€” go forth and slay those requests, mwah πŸ’…πŸ«Ά