APIs 101 with Postman!

A postman is a very famous tool for interacting with HTTP API clients that enable Developers to generate, share, verify and file APIs. Postman offers its users a pleasant GUI for generating requests and responses.

Postman is essential for the user in terms of executing APIs, as once you have entered and stored them you can absolutely use them moreover repeatedly without having to recollect an appropriate endpoint, headers, API key, etc. It enables applications to obtain limited access to the user on the HTTP service like Facebook, GitHub, Twitter, etc. In other words, it helps the user to access the third-party application using the Authorizing token.

What is Postman API?

Postman is an API platform for constructing and utilizing APIs in an efficient manner. Postman makes every step of the API lifecycle easier and streamlines collaboration so that we can create better APIs much faster.

API Requests and Responses

A query would possibly come into your thoughts that how does Postman work API?

Well, Postman is a pretty interactive and automatic tool for verifying the API. It works in the backend and ensures that it is working as expected. Postman creates a request and delivers the response to ensure that it carries the element that we need in the API. Postman lets us build, test, and modify the API.

The API responds to each request with an HTTP status indicating whether the request concludes to be successful, along with a JSON response. The JSON reaction includes:

Success Elements

The very first element of any API response might be the “Success” element, with a purpose to either be true or false. Example:
"success": true

Successful GET Responses

When a GET request correctly executes, the second element in the response may be the payload, a good way to include the data requested. Example of a successful GET to the right:

Successful GET response

{
"success": true,
"payload": {
"user_id": 1,
"first_name":"Danny"
...
}
}

Successful POST Responses

When a POST correctly executes, the payload element may be a success message and an id element may be returned indicating the unique identity notification of the object that was created. Example of a successful POST to the right:

Successful POST response

{
"success": true,
"payload": "user updated with ID 4",
"id": 4
}

Successful PUT/DELETE Responses

When a DELETE or PUT request executes successfully, the “payload” element will be a collection of messages and use data for every affected object. Example of a successful POST to the right:

Successful PUT/DELETE response

{
"success": true,
"payload": [
{
"id": 1,
"success": false,
"error_code": "AD_BAD_VALIDATION",
"message": [
"ERROR: Error creating campaign_budget, field improperly formatted decimal"
]
},
{
"id": 30,
"success": true,
"message": "campaign updated successfully"
}
],
"errors": [
"ERROR: campaign update: 1 updated successfully, 1 with errors"
]
}

HTTP Codes

HTTP status codes signify whether a request was successful or interrupted. If the response’s HTTP code is 200, all worked well. Here is the table of codes representing various other outcomes:

How does the Postman tool work?

Postman can create a request and give the response to make sure that it contains the element that we want in the API.

It has the capacity to make numerous forms of requests like Get, Post, Put, Patch, Delete and keep the API for later use. It can be saved in the environment variable for future purposes as well.

Postman permits to generate a script/test for the API to check the response. Additionally, Postman provides us with the characteristic of “Snippets” through which we can generate the code by the use of several languages like Java, Python, C, etc.

Testing the Postman API following factors have to be considered:

  1. Verify the predicted end result.
  2. Verify an appropriate status code.
  3. Check for response time.

Postman allows running the collection containing a collection of APIs using the feature called “Collection runner” and suggests the end result with the matter of Pass and Fail to check.

How does Postman work internally?🤔

Hey, are you curious about Postman’s inner mechanism? As we recognized that Postman is an API tool that allows us to send a request and get a response in return. Postman guarantees that the service is up and jogging as expected. It allows hitting the API endpoints by creating the request in line with the necessities and verifying the response parameters like status code, headers, and the actual response body.

Features provided by Postman are as follows:

  1. API test development
  2. Setting up mock endpoints for API
  3. Assertions for the response obtained from API
  4. Integration with CI-CD tools like Jenkins etc.
  5. Automating API tests

How to apply environments variables?

Broadly Postman consists of 2 types of variables namely global and environment variables. Global variables are used for all sorts of requests, while environment variables are described as per the specific environment created. Global variables are edited from the eye-shaped icon in the pinnacle right corner as soon as they’re added. Postman permits putting the environment variable by using the snippets given beside the test script editor or by creating the script using -

pm.environment.set(“variablekey”, “variablevalue”);

Also, the setting of the global variable is possible by using the snippets given beside the test script editor or by creating the script using -

pm.globals.set(“variablekey”, “variablevalue”);

Once the environment and global variables are defined it could be used in the request within the given format followed by the curly braces — {{variable_name}}.

Thanks for reading!Hope you enjoyed the letters that my Postman sent you via APIs 😂

#PostmanStudent #PostmanAPI

--

--

--

(MAIT)Sophomore | CSE(Major) | Competitive Programmer | Google Cloud | Programming | Python Developer | Technical Writer | Open-Source Contributor | Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

筆記 Jenkins 架在區網mac上

How To Install Django and Run Your First Project…

Transform Any Text Into A 100% Human-Sounding

“Who moved my data?” A Lazy Django’s Queryset Tale

Puppet roles and profiles - my opinion essay

Hadoop Admin Interview Questions and Answers : Part 1

Azure API for FHIR (Part 1), Set Up and Configure

Ark: Survival Evolved Server Cluster Guide

Ark: Survival Evolved art

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nidhi Chaurasia

Nidhi Chaurasia

(MAIT)Sophomore | CSE(Major) | Competitive Programmer | Google Cloud | Programming | Python Developer | Technical Writer | Open-Source Contributor | Enthusiast

More from Medium

11/2021- A Better Programmer

DYNAMIC LIBRARIES

Mocha starter project