Skip to content

HTTPie

https://httpie.io/

  • Intro tutorial
Terminal window
http DOMAIN/PATH
Terminal window
https DOMAIN/PATH
Terminal window
http :8000 # GET http://localhost:8000
Terminal window
http POST :8000 # or PUT, PATCH, etc.
Terminal window
http :8000 color=red food=pizza

The above POSTs a simple object to http://localhost:8000/:

{
"color": "red",
"food": "pizza"
}

The POST method was emitted, as it is the default when providing payload variable(s). Note: The whitespace in the JSON above is for readability, HTTPie would not usually include unnecessary spaces or line breaks.

Terminal window
http ... age:=44 learning:=true name=Claus

The above sends this object:

{
"age": 44,
"learning": true,
"name": "Claus"
}
Terminal window
http -v ...
Terminal window
http ... param1==2 param2==5 # ...?param1=2&param2=5
Terminal window
http --offline ...
Terminal window
http ... X-My-Custom-Header:my-value

POST form data (application/x-www-form-urlencoded)

Section titled “POST form data (application/x-www-form-urlencoded)”
Terminal window
http -f ... param1=value param2="another value"...
# or
http --form ... param1=value param2="another value" ...
Terminal window
http -a USERNAME:PASSWORD ...
Terminal window
http ... User-Agent: ...
Terminal window
http ... category=tools search[type]=id search[id]:=1

…results in this object being sent:

{
"category": "tools",
"search": {
"id": 1,
"type": "id"
}
}
Terminal window
http ... \
search[keywords][]=APIs \
search[keywords][]=CLI

…results in this object being sent:

{
"search": {
"keywords": [
"APIs",
"CLI"
]
}
}

Omit the key:

Terminal window
http ... []:=1 []:=2

…results in this array being sent:

[
1,
2
]

\ escapes [, ] and \

Terminal window
http ... < data/file.json
Terminal window
http --form ... application@/home/claus/Desktop/resume.pdf
Terminal window
http -A bearer -a TOKEN ...

Note: despite bearer requiring a lowercase b in the -A argument, the sent header will bear a capitalized Bearer.

Follow redirects (Location response header)

Section titled “Follow redirects (Location response header)”
Terminal window
http --follow ...
Terminal window
https --verify=no ...
Terminal window
http -b ...
# or
http --body ...
Terminal window
pbpaste | http ...