- Rahul Agrawal
PostMan
As a developer, you'll be creating applications almost exclusively using APIs, which act as a channel of communication between two or more software components. The drawback of this kind of system is that if one component fails, it may have a substantial effect on the other components on which it depends. Therefore, it's essential to thoroughly test your APIs to guarantee the accuracy and predictability of your application.
The approach or combination of methods you pick to test your APIs will ultimately depend on your existing business needs, the resources at your disposal, and the specifics of your implementation. Then Postman is your buddy.

What is Postman
According to postman , 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. most of peoples can code but very few of them can code that others also can understand.
Why we need API Testing ?
To make sure that your API responds appropriately to a wide range of expected and unexpected queries, it is crucial to test it. This procedure is intended to verify the API's dependability.
Is there really a need to automate API testing, advantages of automated testing over manual? Writing tests enables you to constantly check for the accuracy and predictability of your apps. As a result, you should run tests every time your codebase is modified. Such routine jobs are frequently excellent candidates for automation.
Because you can always rely on your tests to highlight any flaws you may have created, automated tests provide you the confidence to make modifications and add new features to your application.
First step towards postman
First download postman latest from
https://www.postman.com/downloads/
also, we will need a Postman account.
If you don’t already have one, .create one for free
https://identity.getpostman.com/signup
You will get a screen like this after completing step:

Basic terminologies in postman
Workspace
Postman workspaces enable you to organize and work together on API projects with your team. Within each workspace you can share APIs, collections, environments, and other Postman elements. When you first open Postman, you will be in your default personal workspace. You can create more workspaces for your personal use and to work with teammates. To create more workspaces, you need to sign in to your Postman account.
Postman enables developers to organize and collaborate on API work using personal workspaces, team workspaces and public workspaces.

API Network
Postman API Network provides a central place for both API consumers and API producers to easily discover, explore, and share APIs. The Postman API Network has two parts: a public network and a private network. The Postman Public API Network is open to the entire API community, while the Postman Private API Network is for your team only. Postman has a worldwide community of 20 million developers, and the Public API Network is this community’s go-to place to discover, explore, and share APIs. There are more than 2,000 APIs (and more than 5,000 API templates that help you explore new uses of popular APIs) hosted on the Public API Network.

Collection
Postman Collections are a group of saved requests. Every request you send in Postman appears under the History tab of the sidebar. On a small scale, reusing requests through the history section is convenient. As your Postman usage grows, it can be time-consuming to find a particular request in your history.
Environment
An environment is a set of variables you can use in your Postman requests. You can use environments to group related sets of values together and manage access to shared Postman data if you are working as part of a team.
Getting started with Postman
First step towards postman is to create Workspace . Create workspace named anything related to project , also keep it personal as far as learning is concerned , after that for collaboration it can be in Team or public

Setting up variables
Variables are constant values that are used more often like URL, tokens, port, etc. Instead of mentioning it every time , use variable to declare values so that if the value changes , we didn’t need to change in every request

The naming of variables should be as short as possible and it needs to mean so that others can also understand.

Creating first Collection
We can set up collection variables at the time of creation, these are variables that can be accessed only within that collection Also, we can set up authorization along with collection so that APIs of that collection can use that authorization to send the request by default, later we can modify the authorization parameter as per API Also, test and per-request tests can be written for entire APIs inside that collection, we are learning test cases in the next chapter.

Creating first API request
There are some things that you should know before writing an API request REST request methods like GET, POST, etc. and their use Request headers Data Payload that we need to send along with request according to a request method.
Create a request using the + icon :

Setup request method
According To Your requirement , you can use GET , POST , PUT , DELETE , PATCH , OPTIONS , HEAD , TRACE , CONNECT , etc.

Setup data payload that needs to send along with the request.

There are various options available to send data like JSON payload, form data, raw data, etc.
After that first, save API in the collection by pressing “ctrl + s “ or by clicking the “save” icon:

On the saving page we need to title the API request along with choosing the collection.

After saving you will notice,

Sending First Request to the server
After creating a request, add a URL parameter for the request, we can use a variable for that also For using variables, press “{{” and after that select variable.

After that click on “send” button
Response analysis
After sending a request to the IP endpoint , in our case google.com we will get this type of screen.

It contains response status, time requires to reach, and size of the response payload
Also, cookie and response headers sent by the server can be seen.
Testing in Postman
Every time at testing, the tester/developer is unable to see test results to verify API response and working. To overcome that, POSTMAN has introduced a test. the test contains scripts that are nothing but JavaScript code that is used to compare response and expected value. After comparing, test results show whether API has passed the test or not. postman also provides pre-written scripts to save time to write scripts.

For checking if status code is as expected as it should be , we can write script for that.


Here second test is supposed to be failed as it was GET request
Debugging Request
As many times, testing requires a complete analysis of request so postman also provided a tool which can help to make a complete analysis of request. the tool name is “console” It is available in the left bottom corner.


Postman Runner
As for testing every time running an API request is not feasible as there can be hundreds of different APIs so postman introduced a tool named runner that can help to sort this problem. By just dragging APIs to the runner, we can perform simultaneous testing of APIs. we can save the runner configuration so that we can use it later or in every iteration of software development We can drag a complete collection or collections at a time to run.



Thanks for reading!
If you find our content interesting and are willing to know more, do comment and let us know. We will keep bringing more quality content for you! :)