How to simulate API latency during development
Tags: requestly, api, apidevelopment
Published: 2023-06-07 09:07:16

---
title: How to simulate API latency during development
published: true
date: 2023-06-06 15:00:54 UTC
tags: requestly,api,apidevelopment
canonical_url: https://requestly.com/blog/simulate-api-latency-during-development/
---

![](https://cdn-images-1.medium.com/max/1024/1*jR8fWsJqL6yqo9t09dNf2Q.png)

Building robust applications that can handle varying network conditions is crucial. In the real world, network conditions are unpredictable, and API latency can vary significantly. Latency refers to the delay in response time when making requests to an API, and it can greatly impact the user experience. Slow response times can lead to frustrated users, increased bounce rates, and even lost business opportunities.

By simulating API latency, you can assess how your application behaves when faced with delays. This includes evaluating how loading indicators are displayed, how the application handles user interactions during latency, and how it recovers from potential errors or timeouts. Testing under different latency conditions helps you ensure a smooth and satisfactory user experience.

This article focuses on how we can simulate API latency using the Requestly Desktop app

### Use Cases:

Below are some use cases where you might want to add delay to the network requests :

1. Test the performance of your web app on a slower network.
2. Test your app’s behavior when one or more APIs respond slowly, i.e., API Latency has gone up.
3. Check if any race conditions exist when some resource X gets loaded after/before another resource Y.
4. Test the impact of the loading speed of an external resource on your app.

### Simulating API latency using the Requestly Desktop app

To simulate a delay in network requests using Requestly, we will create a [Delay rule](https://docs.requestly.io/desktop-app/mac/http-modifications/delay-rule) to add delay to a specific network request. If you haven’t already installed the Requestly Desktop app, you can download it from [here](https://requestly.com/desktop).

In this example, we will add a delay to the loading of searched images when an image search is done on [Unsplash](https://unsplash.com/).

1. Download and Install the [Requestly desktop app](http://requestly.com/desktop).
2. Open the app, and click **Connect Apps.**
3. Choose the browser you want to launch and search for [unsplash.com](http://unsplash.com)
4. From the traffic table, right-click on the network request on which you want to add delay and select **Delay Request** from the dropdown menu under **more modification options.**
5. Here, give the rule a name and set the delay duration to 4000 ms and save the rule. You can remove the query param from the source condition if you want a delay on any image search.
6. After saving the rule, search your image again, and you will see a delay in loading the searched images.

![](https://cdn-images-1.medium.com/max/1024/1*jbaCJB7dPzOdleBVvqIX6A.gif)

You can adjust the delay duration as per your requirement and test your application under different network conditions.

By simulating API latency, you can catch potential issues before they impact your users. Utilizing the Requestly Desktop app to add delay to network requests is a simple and effective way to test your application under different network conditions. Don’t wait for users to complain about slow performance — be proactive and test your application today.

_Happy Debugging!_

Requestly is an Open-Source frontend development platform with essential tooling & integrations that helps frontend developers write, test & debug their code 10x faster. Using Requestly, you can create mock API endpoints, test, validate & override API responses, modify request & response headers, set up redirects (Map local, Map remote), and use Requestly sessions for faster debugging.

_Originally published at_ [_https://requestly.com_](https://requestly.com/blog/simulate-api-latency-during-development/)_._

* * *