Skip to main content

HTTPie is a command line HTTP client with an intuitive UI, JSON support, syntax highlighting, wget-like downloads, plugins, and more. It aims to be easier to use than cURL.

# To send a GET request (default method with no request data):
http <>

# To send a POST request (default method with request data):
http <> <hello=World>

# To send a POST request with redirected input:
http <> < <file.json>

# To send a PUT request with a given JSON body:
http PUT <> <hello=world>

# To send a DELETE request with a given request header:
http DELETE <> <API-Key:foo>

# To show the whole HTTP exchange (both request and response):
http -v <>

# To download a file:
http --download <>

# To follow redirects and show intermediary requests and responses:
http --follow --all <>

# ---

# Custom HTTP method HTTP headers and JSON data:
http PUT X-API-Token:123 name=John

# Submitting forms:
http -f POST hello=World

# See the request that is being sent using one of the output options:
http -v

# Use Github API to post a comment on an issue with authentication:
http -a USERNAME POST body='HTTPie is awesome!'

# Upload a file using redirected input:
http < file.json

# Download a file and save it via redirected output:
http > file

# Download a file wget style:
http --download

# Use named sessions_ to make certain aspects or the communication
# persistent between requests to the same host:
# http --session=logged-in -a username:password API-Key:123
http --session=logged-in

# Set a custom Host header to work around missing DNS records:
http localhost:8000

# Simple JSON example:
http PUT name=John

# Non-string fields use the := separator, which allows you to embed raw
# JSON into the resulting object. Text and raw JSON files can also be
# embedded into fields using =@ and :=@:
http PUT name=John age:=29 married:=false hobbies:='["http", "pies"]' description=@about-john.txt bookmarks:=@bookmarks.json

# Send JSON data stored in a file:
http POST < person.json

# Regular Forms
http --form POST name='John Smith' cv=@~/Documents/cv.txt

# File Upload Forms
# If one or more file fields is present, the serialization and content
# type is multipart/form-data:
http -f POST name='John Smith' cv@~/Documents/cv.pdf

# To set custom headers you can use the Header:Value notation:
http  User-Agent:Bacon/1.0  'Cookie:valued-visitor=yes;foo=bar' X-Foo:Bar  Referer:

# Basic auth:
http -a username:password

# Digest auth:
http --auth-type=digest -a username:password

# With password prompt:
http -a username

# Authorization information from your ~/.netrc file is honored as well:
cat ~/.netrc
    login httpie
    # password test

# You can specify proxies to be used through the --proxy argument for each
# protocol (which is included in the value in case of redirects across
# protocols):
http --proxy=http: --proxy=https:

# With Basic authentication:
http --proxy=http:http://user:pass@

# --verify=no (default is yes):
http --verify=no

# You can also use --verify=<CA_BUNDLE_PATH> to set a CUSTOM CA BUNDLE path:
http --verify=/ssl/custom_ca_bundle

# To use a CLIENT SIDE CERTIFICATE for the SSL communication, you can pass
# the path of the cert file with --cert:
http --cert=client.pem

# If the PRIVATE KEY is not contained in the cert file you may pass the
# path of the key file with --cert-key:
http --cert=client.crt --cert-key=client.key

# You can control what should be printed via several options:
  # --headers, -h   Only the response headers are printed.
  # --body, -b      Only the response body is printed.
  # --verbose, -v   Print the whole HTTP exchange (request and response).
  # --print, -p     Selects parts of the HTTP exchange.
http --verbose PUT hello=world

# Print request and response headers:
  # Character   Stands for
  # ----------- -------------------
  # H           Request headers.
  # B           Request body.
  # h           Response headers.
  # b           Response body.
http --print=Hh PUT hello=world

# Let's say that there is an API that returns the whole resource when it
# is updated, but you are only interested in the response headers to see
# the status code after an update:
http --headers PATCH name='New Name'

# Redirect from a file:
http PUT X-API-Token:123 < person.json

# Or the output of another program:
grep '401 Unauthorized' /var/log/httpd/error_log | http POST

# You can use echo for simple data:
echo '{"name": "John"}' | http PATCH X-API-Token:123

# You can even pipe web services together using HTTPie:
http GET | http POST

# You can use cat to enter multiline data on the terminal:
cat | http POST
    # ^D
cat | http POST Content-Type:text/plain
    - buy milk
    - call parents

# On OS X, you can send the contents of the clipboard with pbpaste:
pbpaste | http PUT

# Passing data through stdin cannot be combined with data fields specified
# on the command line:
echo 'data' | http POST more=data   # This is invalid

# AN ALTERNATIVE TO REDIRECTED stdin is specifying a filename (as
# @/path/to/file) whose content is used as if it came from stdin.

# It has the advantage that THE Content-Type HEADER IS AUTOMATICALLY SET
# to the appropriate value based on the filename extension. For example,
# the following request sends the verbatim contents of that XML file with
# Content-Type: application/xml:
http PUT @/data/file.xml

# Download a file:
http >

# Download an image of Octocat, resize it using ImageMagick, upload it
# elsewhere:
http | convert - -resize 25% -  | http

# Force colorizing and formatting, and show both the request and the
# response in less pager:
http --pretty=all --verbose | less -R

# When enabled using the --download, -d flag, response headers are printed
# to the terminal (stderr), and a progress bar is shown while the response
# body is being saved to a file.
http --download

# You can also redirect the response body to another program while the
# response headers and progress are still shown in the terminal:
http -d |  tar zxf -

# If --output, -o is specified, you can resume a partial download using
# the --continue, -c option. This only works with servers that support
# Range requests and 206 Partial Content responses. If the server doesn't
# support that, the whole file will simply be downloaded:
http -dco

# Prettified streamed response:
http --stream -f -a YOUR-TWITTER-NAME track='Justin Bieber'

# Send each new tweet (JSON object) mentioning "Apple" to another
# server as soon as it arrives from the Twitter streaming API:
http --stream -f -a YOUR-TWITTER-NAME track=Apple | while read tweet; do echo "$tweet" | http POST ; done

# Create a new session named user1 for
http --session=user1 -a user1:password X-Foo:Bar

# Now you can refer to the session by its name, and the previously used
# authorization and HTTP headers will automatically be set:
http --session=user1

# To create or reuse a different session, simple specify a different name:
http --session=user2 -a user2:password X-Bar:Foo

# Instead of a name, you can also directly specify a path to a session
# file. This allows for sessions to be re-used across multiple hosts:
http --session=/tmp/session.json example.orghttp --session=/tmp/session.json admin.example.orghttp --session=~/.httpie/sessions/ example.orghttp --session-read-only=/tmp/session.json

# ---

# To send a GET request (default method with no request data):

# To send a POST request (default method with request data):
http hello=World

# To send a POST request with redirected input:
http < file.json

# To send a PUT request with a given json body:
http PUT hello=world

# To send a DELETE request with a given request header:
http DELETE API-Key:foo

# To show the whole HTTP exchange (both request and response):
http -v

# To download a file:
http --download