HTTpie examples

CURL is the default tool to do HTTP requests from the command line. HTTPie tries to improve it by making it more user friendly, including a more natural syntax and colorized output.

Install it via the instructions on Installation Page.

To use it do:


Only see the response headers (h):

http -p 'h'

Only print the response body (b):

http -p 'b'

Use different HTTP action:

http POST
http PUT

Print the request headers:

http -p 'H'

Define and print the request body in JSON format. Note the Content-Type header.

http --print 'HB' POST  rating='123'

Define and print the request body in form encoded format. Again note the Content-Type header (-f stands for --form).

http --print 'HB' -f POST rating='123'

Pass parameter via the URL string. Check the URL path in the first line:

http --print 'H' POST rating=='123'

Pass a new header:

http --print 'Hb' GET Accept:text/html

And this concludes our quick cheatsheet for HTTPie.