RateLimitHeaders is a .NET library for parsing IETF RateLimit headers and enabling proactive rate limit awareness in HTTP clients. It automatically delays requests before hitting 429 errors, integrates with Polly v8 resilience pipelines, and provides a drop-in DelegatingHandler for IHttpClientFactory.
Documentation | Getting Started | API Reference
| Package | Description |
|---|---|
| RateLimitHeaders | Core library with IETF header parsing and IHttpClientFactory DelegatingHandler |
| RateLimitHeaders.Polly | Polly v8 resilience pipeline integration |
dotnet add package RateLimitHeaders
dotnet add package RateLimitHeaders.Polly # Optional: for Polly integration// Register with IHttpClientFactory
services.AddHttpClient("MyApi")
.AddRateLimitAwareHandler(options =>
{
options.EnableProactiveThrottling = true;
options.QuotaLowThreshold = 0.1; // Warn at 10% remaining
})
.AddStandardResilienceHandler();
// Or use with Polly resilience pipelines
var pipeline = new ResiliencePipelineBuilder<HttpResponseMessage>()
.AddRateLimitHeaders(options => options.EnableProactiveThrottling = true)
.AddRetry(new RetryStrategyOptions<HttpResponseMessage>())
.Build();-
IETF Standard Parsing - Parses
RateLimitandRateLimit-Policyheaders per draft-ietf-httpapi-ratelimit-headers-10 -
Proactive Throttling - Automatically delays requests when quota is low, preventing 429 errors before they happen
-
Polly Integration - Works seamlessly with Polly v8 resilience pipelines alongside retry and circuit breaker strategies
-
DelegatingHandler - Drop-in handler for IHttpClientFactory with full dependency injection support
-
Extensible - Implement
IThrottlingAlgorithmfor custom throttling strategies -
Observable - Callbacks for rate limit info, quota warnings, and throttling events
Explore the Full Documentation →
Comprehensive guides, configuration options, custom algorithms, and more.
| Package | .NET 8 | .NET 9 | .NET 10 |
|---|---|---|---|
| RateLimitHeaders | Yes | Yes | Yes |
| RateLimitHeaders.Polly | Yes | Yes | Yes |
We welcome contributions! Whether it's bug reports, feature requests, or code contributions.
This project is licensed under the MIT License.
- Polly - The .NET resilience library
- Microsoft.Extensions.Http.Resilience - Official Polly integration for HttpClient