If you’re a SE, you’ve probably came across thing thing called Postman, especially if you’re dealing with an API. In another article, I talked about what an API was, and in this blog I’m going to be talking about how Postman can help you work with an API.
So what is Postman?
When trying to dissect RESTful APIs made by others or evaluate those you have developed yourself, Postman is a great tool. It provides a sleek user interface in which to make HTML requests, just to test the functionality of an API without the hassle of writing a bunch of code.
For instance, if you wanted to make a GET request off of someone else’s API or your API, you would have to write out a whole new route and feature, then you would have to define what you want the response to look like with more code, and finally you would have to print out the response to the console or provide some other way to actually display the response. Even so, to create a working app using this API, you will probably need to write all this down anyway, but doing all this to simply evaluate the functionality of an API is unnecessarily complicated and time consuming when there is something like Postman exists for this purpose.
With Postman, a test like that is much more streamlined. All I have to do is plug the route into the address bar, choose the GET answer method on the left-hand side of the drop-down box, punch the “Headers” section of my API key, specify that I want the response in “pretty” JSON format, and hit send.
Then, in easy-to-read JSON, I get the response data with a status code of 200, verifying that the GET request was successful.
In the example above I made a simple GET request to my local API. I added the route in the address bar, and hit send, and depending on what’s in your code, the output should show in console.
What about other requests?
Postman can also run PUT, PATCH, DELETE, and various other HTTP methods, and has utilities to help build APIs as well. For Mac, Windows, Linux, and also as a Chrome app, free and paid versions are available. As show in the picture below:
I hope this blog has helped you understand what Postman is and how beneficial it could be if you’re building an app, or just simply want to test out an API.