Skip to content

XeClutch/Oz.RateLimitedHttpClient

Repository files navigation

Oz.RateLimitedHttpClient NuGet NuGet Downloads

RateLimitHttpClient is a HttpClient wrapper implementing SimpleRateLimiter.

Usage

Import the namespace

using Oz.RateLimiting;

Establish a rate limit

Let's get setup for 200 requests per hour.

var rateLimiter = new SimpleRateLimiter(200, TimeSpan.FromHours(1));
var httpClient = new RateLimitedHttpClient(rateLimiter);

Abiding by the rate limit

Let's make some API calls to jsonplaceholder (a free, fake API for testing).

for (int i = 1; i <= 5000; i++) {
    var response = await httpClient.GetAsync($"https://jsonplaceholder.typicode.com/photos/{i}");
}

About

An HttpClient wrapper implementing SimpleRateLimiter.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages