Rate limiting prevents an API from being saturated with requests, ensuring that the service provided is not degraded. Rate limiting is a tactic commonly employed by an API but can also be employed by a client that consumes from an API. We might see the latter scenario for an application consuming from a third-party API that imposes request-rate restrictions with punitive measures for consumers routinely in violation of the given restrictions. Recently, I encountered such a scenario.

A visualization of a rate-limited API client
A visualization of a rate-limited API client
Figure 1: A visualization of a rate-limited API client

Precedence for a Rate-Limited API Client

Some time ago, I started work on a personal project: a web app that displays match statistics about highly ranked players in a…


In the first article of this series, we implemented a rate limiter in .NET Core using the sliding window algorithm with the intention that it will be used by an application to self-limit its requests to an API. Before we can put our implementation into practice, we first need to validate that it functions as intended.

In this article, we will discuss how to validate our rate limiter with unit tests. We will first setup the test class and several helper methods that can be reused throughout our unit tests. We will then turn our attention towards the unit tests…

Gopherchucks

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