API smoke tests made easy with Postman monitoring

Pranav Phalgun
Healint-Engineering&data
3 min readAug 26, 2021

Postman has established itself as a very popular tool in API lifecycle management. It is quite versatile in its capabilities and an often-overlooked feature is the Postman monitoring functionality. Smoke tests can aid in monitoring the QoS of the application during the development cycle as well as in production. In this story, we setup an API test automation suite using Postman to monitor a sample API.

Smoke tests to detect bugs / issues early.

#1. Prerequisites

A Postman account — A free postman account can be signed up here, which allows up to 1000 API calls per month for monitoring, suffices for this story. After signing up, either the postman desktop client or it’s web interface can be used to setup the monitors.

#2. API we are monitoring — Dog API by Dog CEO

Dog API is available for consumption for free and is an amazing resource to monitor as we dive into the implementation. It offers open-source dog images categorized by dog breed, which can be uploaded by anyone. We will monitor the following APIs

  • List All Breeds: Returns a list of all breeds and their sub-breeds

GET https://dog.ceo/api/breeds/list/all

  • Random image: Fetch a random image from all available dog images

GET https://dog.ceo/api/breeds/image/random

A complete documentation of all the APIs is available here and if you got paw friends, the process to upload images to the collection is here.

#3. Setting up Postman Dogs API collection

In the default workspace, we create the Dogs API collection and add the two GET requests we are interested to monitor.

GET Requests are setup in the collection.

There is no need to setup authorization, request headers, or query parameters in this example.

#4. Setting up Postman monitors

We will setup postman monitor to monitor these two endpoints.

It can be accessed by visiting Monitors > Create a Monitor

After choosing default options, we have a continuous monitor calling these API endpoints once every hour to verify that the API is responding.

Dog Monitor is running!

#5. Making assertions

We can add tests in postman requests for better validation of the APIs.

In the List All Breeds request, we will add two tests. One for asserting that the HTTP response status code is 200 and the other will ensure that the response content-type header is “application/json”

In the Get Random Image request, we can test for the above two conditions as well as an additional assertion that ensures that the response contains a valid JPEG image URL. The response returned by the API is

Fetch a Random Dog’s Image Response

We can add the below test to ensure that the field message contains a JPEG image URL.

More information on postman tests and assertions is available here.

#6. Next steps

Postman monitoring is a quick way to setup API monitoring and validation before delving into specialised tools. The most important APIs of an application that enable key workflows can be monitored continuously in pre-prod as well as production environments.

If we want to integrate this functionality into CI/CD process as a build quality metric, newman-cli is the place to start. Happy monitoring!

--

--