Skip to content

Latest commit

 

History

History
21 lines (20 loc) · 1.01 KB

README.md

File metadata and controls

21 lines (20 loc) · 1.01 KB

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}");
}