Benchmarking a Web API using Postman A step-to-step guide to estimate the performance of a Web API using a great tool such as Postman

Benchmarking di una Web API con Postman: misurazioni rapide e utili in pochi passaggi

Benchmarking a Web API is one of the most useful things we can do when we want to check how fast it is: knowing the execution time of a given HTTP request - such as a GET on a given endpoint - is always helpful, especially when we're working on web projects where the overall page load time heavily depends on API calls that return data to render, populate and manage HTML content.

In this article, we’ll see how we can perform a Web API benchmark using Postman, a powerful HTTP client that allows you to build, test and modify APIs, as well as perform functional and regression testing - manually and through automated scripts - for various environments and request flows.

#1. Create a new Request

The first thing we need to do is to create a new Request. To do that, launch Postman and click on the “New” button, then select “HTTP Request” from the available options. Once the request is created, you’ll be able to:

  • Set the request HTTP verb (GET, POST, etc.)
  • Specify the request URL (endpoint)
  • Add optional parameters, headers, authentication, and so on

#2. Send the Request

Once the request is configured, click on the “Send” button and wait for the response. When the response is received, you’ll see a number of useful info on the lower part of the Postman interface, such as:

  • Response status
  • Response time (in milliseconds)
  • Response size (in KB)

This is basically what we wanted: a reliable measure of how much time that specific request took to return a response.

#3. Automate the Process

If we want to improve the effectiveness of our benchmark, we can make the whole process a bit more automated. For example, we could write a Postman test that writes the response time value to the console or to a variable, so we can easily compare it with other requests.

To do that, click on the “Tests” tab and type the following JavaScript code:

Alternatively, you can store the value into a Postman environment variable:

#4. Run Multiple Times

Another useful approach would be to run the request multiple times and evaluate the average time taken to complete. This can be done using the Collection Runner feature:

  1. Create a new Collection
  2. Add your request to the Collection
  3. Click on the “Runner” icon
  4. Choose the Collection
  5. Set the number of iterations (e.g. 50)
  6. Click “Run”

The Collection Runner will execute your request the specified number of times and will show you the execution time for each run, allowing you to calculate averages and identify anomalies.

Conclusion

Using Postman to benchmark your Web APIs is a quick and easy way to gain insight into their performance, especially if you don’t need to simulate concurrent users or load scenarios. For more complex benchmarking and load testing, you might want to use tools specifically built for that purpose, such as Apache JMeter, k6, or NBomber.

For additional details on such an approach we strongly suggest to read the second part of this post, where we explain how to perform advanced Web API benchmarks with NBomber.

However, for most development and testing scenarios, Postman provides all the tools you need to evaluate and optimize your HTTP requests efficiently.

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.