Postman was my go to tool when I considered making a http request. That all changed when I found out httpie gives a very easy and short API precisely for this. In this post I will show why I like httpie. The full documentation can be found on the httpie page.

Together with the tool that lets you scroll through your command history (as discussed in a previous post on fish shell), httpie is my new default tool to make http requests.

Installation

On my mac I typed:

brew install httpie

Getting started

Say you want to make a GET request to an API you have running locally. This would be the command:

Screenshot 2019 06 28 at 08.29.59 - HTTPIE

As you can see GET is the default method and you don’t even have to type localhost! The -v is there to see the request that is generated and see how the response json is pretty printed.

Json

Now we want to do something a bit more complicated. We want to POST a json body to create a product.

Screenshot 2019 06 28 at 08.35.06 - HTTPIE

We can just define the properties of the json and initialise them with =. Or we can write the full json string with :=. Both are used in the example above.

Headers

What if we want to do even more, like setting headers:

Screenshot 2019 06 28 at 08.48.20 - HTTPIE

Just use single quotes, then name : value. It’s as easy as that. For basic auth there is an even faster notation.

Screenshot 2019 06 28 at 08.42.33 - HTTPIE

As you can see it is very easy to get started with httpie. There are short notations for a lot of http building blocks. Happy http’ing!