Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster. (hitechgazette)
When trying to decipher RESTful APIs created by others or test ones you’ve created yourself, Postman is a fantastic tool. It provides a simple user interface for making HTML requests, eliminating the need to write a lot of code just to test an API’s functionality.
Let’s say I wanted to make a GET request to a Hearthstone fan-made API to look for cards with the word “archer” in their name. If I wanted to test a GET request against this route without using Postman and instead of writing code in something like Flask, I’d have to create a new route and function to make the request, then specify what I want the response to look like with more code, and finally print the response to the console or provide some other way to actually view the response. Granted, I’d have to write all of this anyway if I wanted to make a working app with this API, but doing so just to test an API’s functionality is unnecessarily tedious and time-consuming when tools like Postman are available.
Methods
Postman supports PUT, PATCH, DELETE, and a variety of other request methods, as well as providing API development tools. There are free and paid versions available for Mac, Windows, Linux, and Chrome.
Many endpoint interaction methods are available in Postman. Here are a few of the most commonly used, along with their functions:
- GET: Obtain information.
- POST: Add information.
- PUT: Replace the data.
- PATCH: Correct some information.
- DELETE: To remove information from a database, use the DELETE command.
Types of Response Codes
When we use Postman to test APIs, we usually get a variety of response codes. The following are a few of the most common:
For example, ‘102 Processing’ in the:
- 100 Series > Temporal responses.
- ‘200 Ok’ is an example of a response in which the client accepts the request and the server processes it successfully.
- ‘301 Moved Permanently,’ for example, is one of the 300 Series responses related to URL redirection.
- Client error responses in the 400 series, such as ‘400 Bad Request.’
- Server error responses in the 500 series, such as ‘500 Internal Server Error.’
Collections
Postman allows you to group similar requests together. This feature is referred to as ‘collections,’ and it aids in the organization of tests.
These collections are folders where requests are kept and can be organized however the team sees fit. They can also be exported and imported.
Postman also allows us to create different environments by generating/using variables, such as a URL variable for different test environments (dev-QA), which allows us to run tests in different environments using existing requests.