HTTPie
Resources
Section titled “Resources”Videos
Section titled “Videos”- Intro tutorial
Simple GET example
Section titled “Simple GET example”http DOMAIN/PATHUse HTTPS
Section titled “Use HTTPS”https DOMAIN/PATHlocalhost is the default domain
Section titled “localhost is the default domain”http :8000 # GET http://localhost:8000Using other methods
Section titled “Using other methods”http POST :8000 # or PUT, PATCH, etc.Simple JSON POST
Section titled “Simple JSON POST”http :8000 color=red food=pizzaThe 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.
JSON property that is not a string
Section titled “JSON property that is not a string”http ... age:=44 learning:=true name=ClausThe above sends this object:
{ "age": 44, "learning": true, "name": "Claus"}Show request (headers/body)
Section titled “Show request (headers/body)”http -v ...Query parameters
Section titled “Query parameters”http ... param1==2 param2==5 # ...?param1=2¶m2=5Dry-run (show request that would be sent)
Section titled “Dry-run (show request that would be sent)”http --offline ...Set request header
Section titled “Set request header”http ... X-My-Custom-Header:my-valuePOST form data (application/x-www-form-urlencoded)
Section titled “POST form data (application/x-www-form-urlencoded)”http -f ... param1=value param2="another value"...# orhttp --form ... param1=value param2="another value" ...Basic auth
Section titled “Basic auth”http -a USERNAME:PASSWORD ...Remove default User-Agent header
Section titled “Remove default User-Agent header”http ... User-Agent: ...Build a more complex JSON object
Section titled “Build a more complex JSON object”http ... category=tools search[type]=id search[id]:=1…results in this object being sent:
{ "category": "tools", "search": { "id": 1, "type": "id" }}Append to a JSON array
Section titled “Append to a JSON array”http ... \ search[keywords][]=APIs \ search[keywords][]=CLI…results in this object being sent:
{ "search": { "keywords": [ "APIs", "CLI" ] }}Send a JSON array
Section titled “Send a JSON array”Omit the key:
http ... []:=1 []:=2…results in this array being sent:
[ 1, 2]Escape character
Section titled “Escape character”\ escapes [, ] and \
Send file contents as raw request body
Section titled “Send file contents as raw request body”http ... < data/file.jsonUpload a file using multipart/form-data
Section titled “Upload a file using multipart/form-data”http --form ... application@/home/claus/Desktop/resume.pdfUse Bearer authorization
Section titled “Use Bearer authorization”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)”http --follow ...Do not verify host certificate (insecure)
Section titled “Do not verify host certificate (insecure)”https --verify=no ...Output only response
Section titled “Output only response”http -b ...# orhttp --body ...Send clipboard (macOS)
Section titled “Send clipboard (macOS)”pbpaste | http ...