Postman: A Unique API Development Environment

Photo by Xavier Massa on Unsplash

Curious about Postman? And no, it’s not related to a postal carrier. Instead, it’s a must-have tool for developers who work with APIs regularly. Let’s take a look.

RESTful Web Services

First, let’s review RESTful web services. Representational state transfer (REST) is an architectural style that specifies constraints, such as the uniform interface. If applied to a web service, these constraints induce desirable properties, such as performance, scalability, and modifiability, that enable services to work better on the web.

The restful API uses HTTP methods to retrieve, access, and edit data records. The most commonly used methods are GET, PUT, PATCH, POST, and DELETE, which get a response, edit a response, add a patch, post a request and delete an existing API, respectively.

About Postman

Now let’s move on to Postman, a powerful HTTP client for testing web services. This app makes it easy to test, develop, and document APIs by allowing users to quickly put together both simple and complex HTTP requests.

Postman REST Client is one of the highest-rated productivity apps in the Chrome Web Store, with more than 348,000 unique users (for both versions) who have shared more than 63,000 collections. Here are just a few of the features that developers love:

  1. History: Postman saves all the API calls made in the history section. A developer can go back to the history and access a previously run API call, which saves the retyping of the entire API call and other information.
  2. Collections: Developers can choose to organize the API calls into different collections and folders. Postman allows you to create a collection of requests, which run in the order they appear in the collection.
  3. Folders: Postman allows developers to create new folders within these collections to better organize their API calls.
  4. Data Formats: Postman supports working with two data file formats, CSV and JSON.
  5. Accessibility: Postman allows you to export the collection of requests and share through a unique URL or by generating a JSON file. Example: If you develop a collection with 10 folders, with each folder having 10 API requests, you can export these 100 API requests as a JSON file and easily share them with the team. Team members can import the shared JSON file and use all the API requests you originally built.
  6. Simplified Testing: Postman provides an environment in which you can write and run tests with no additional setup. The tests are JavaScript code snippets that can test API responses, ensuring that they have met the conditions as specified in the test code. A list of commonly used test snippets appears on the right side of the text editor so that users can add tests to API requests with just one click. You can view test results in the Tests tab of the response viewer as well as in the collection runner. This feature allows developers to test API requests and complex scenarios without having to write a lot of additional code.

Flow of Execution

Now let’s look at how Postman improves the flow of execution. A URL, the type of request, and the body of the request are the three elements that comprise a valid request. When you make a valid API call, Postman initially executes the pre-request scripts, then runs the API call using the body as the input. Finally, it runs all the test cases written in the Tests tab.

When you submit a request, Postman will display the response body, the status code of the URL, the response time for the API call, and the status of the test cases written.

You can also implement Postman on command-line interface using the npm and Newman package. It also supports continuous integration with Travis. Jenkins is another feature that can send notifications of the test results.

Runner and Monitoring

Postman has a monitoring feature that allows the developer to create a monitor, track the collection, and run all requests in the collection on a pre-defined schedule. This feature allows you to execute the requests as often as every 5 minutes or as seldom as once a month. You can configure a monitor to send notifications of the results of the run.

Postman also has a runner option, which you can use to run all test cases in a collection. A developer can choose to automate these requests to be implemented for multiple inputs. We can set the number of iterations before we run the test and feed a CSV file of inputs.

The runner will iterate through the CSV file and run all the requests multiple times for each set of inputs. The final summary of the test run shows the success rate and the failure rates at the end of the run:

Developers will likely find that Postman significantly cuts down on the amount of code they need to write themselves, and it allows for documentation of API calls when you add them to collections. Users can also share collections with others by saving their collections as download links on getpostman.com or as JSON files.

Postman REST Client is a real time saver that makes it easy to test and work with APIs. I believe it’s a must-have tool for developers who regularly work with APIs — from those just beginning to consume APIs for their web and mobile development projects to experienced developers who design, test, and release APIs for public consumption.

To leave you with real-world example, Primitive Logic has been using Postman extensively at one of our client locations to test the API development. The app has made the testing process significantly faster and easier, helping us to deliver on time and — as it requires only a free subscription for unlimited use of each feature — within budget as well. I suggest you give it a try.

Mohammed Zubair is an experienced software developer with a proven history of delivering results in the big data industry. He is skilled at building ETLs in Hadoop and programming in Golang and Java.

Mohammed Zubair, May 2018