February 22, 2018Elias Tounzal5 min read
A postman, or letter carrier (in American English), sometimes colloquially known as a postie, is an employee of a post office or postal service, who delivers mail and parcel post to residences and businesses. Postman is also the name of a powerful graphical HTTP client helpful when working with APIs. I'll introduce a few tricks to get started with it!
To install Postman, go to this link and download the right version for the OS you use.
Launching the app, you should see the following screen:
Click the Request button at the top-left of the modal, and you'll get on the Save Request screen.
Give it a name, create a collection if you don't have any, select a collection and save it.
From there, you'll be able to send a request. For exemple, you can hit the
HTTPCat API. Enter the
https://http.cat/[status_code] URL in the dedicated tab, with the status code of your choice. Press Send and you'll see the response just below.
To illustrate how to do a
POST request, we are going to hit the
https://jsonplaceholder.typicode.com/ URL, on the
So from the same screen, select
POST instead of
GET, and enter the URL in the dedicated tab.
The API we're hitting enables us to send any JSON body, and sends it back in the response, adding it an
id. Let's then send a random object.
Go in the Body tab, check the raw radio button, and make sure that you selected JSON (application/json) on the dropdown on the right.
In the end we obtain this kind of POST requests:
Just press Send and you'll have the response!
On the left of your window, you have a list of your collections. Go over one with your mouse cursor, and you'll see three dots on the bottom-right of it. Click them, then click Export.
You'll get on a modal that asks you to choose the way you want to download your collection. Choose Collection v2, click Export and save it.
To import a collection, click on Import at the top-right of your window, then get in your own files the json you want to import!
The typical use case here is when you work with different environments. Let's say you develop an API which has a production, a staging and a development environments. For each of them, you want to set a
Host and a
token variable, to be able to authenticate.
Click the wheel on the top-right of your screen, then select Manage Environments.
You can now give a name to your environment, and set the variables you need. Click Update when this is done.
You can do this for each one of your environments, then you'll see them in the Manage Environments tab.
Now go back to the main screen, and fill your request with the variables using double curly brackets:
Let's say you want to reproduce a request done on a website. But this request is a very tricky one with, for example, authentication, complicated headers, a big body or a method you don't really know how to use.
Then the best way to replicate this request is to basically copy the entire request directly from your browser.
Let's say we want to get the post request of a research on https://giphy.com/. Open the browser development tools (Right click + Inspect on Chrome). Go in the Network tab and filter the requests by
POST methods. Right click the one you are interested in, and select Copy as CURL.
Now, go back to POSTMAN. On the top-left, click Import, and go in the Paste Raw Text tab. Paste what you copied, and press Import.
Now Send the request and you'll have the answer!
If you want to keep going with Postman, you check this article about Postman Cloud, which explains you how to share and document your API.
And actually there were technically only 4 tricks in this article.. If you find any fifth that would fit here, send it to me and I'll add it!
Web Developer at Theodo