RateLimitHeaders
A .NET library for parsing IETF RateLimit headers and enabling proactive rate limit awareness in HTTP clients.
Packages
Quick Start
// Using with IHttpClientFactory and Microsoft.Extensions.Http.Resilience
services.AddHttpClient("MyApi")
.AddRateLimitAwareHandler(options =>
{
options.EnableProactiveThrottling = true;
options.QuotaLowThreshold = 0.1; // Warn at 10% remaining
})
.AddStandardResilienceHandler(); // Microsoft resilience (retry, circuit breaker, etc.)
// Or using with Polly resilience pipelines directly
var pipeline = new ResiliencePipelineBuilder<HttpResponseMessage>()
.AddRateLimitHeaders(options => options.EnableProactiveThrottling = true)
.AddRetry(new RetryStrategyOptions<HttpResponseMessage>())
.Build();
Features
IETF Standard Parsing
Parses RateLimit and RateLimit-Policy headers per draft-ietf-httpapi-ratelimit-headers-10. Extracts remaining quota, reset time, window size, and partition keys.
Proactive Throttling
Automatically delays requests when quota is low, preventing 429 errors before they happen. Configurable thresholds, delays, and custom throttling algorithms.
Polly Integration
Works seamlessly with Polly v8 resilience pipelines. Add rate limit awareness alongside retry, circuit breaker, and timeout strategies.
DelegatingHandler
Drop-in handler for IHttpClientFactory. Easy integration with ASP.NET Core dependency injection and named/typed HttpClients.
Extensible Throttling
Implement IThrottlingAlgorithm for custom strategies. Built-in percentage-based algorithm with configurable threshold, factor, and max delay.
Observable Events
Callbacks for rate limit info, quota warnings, and throttling events. Perfect for logging, metrics, and alerting when approaching limits.
Supported Frameworks
| Package | .NET 8 | .NET 9 | .NET 10 |
|---|---|---|---|
| RateLimitHeaders | ✅ | ✅ | ✅ |
| RateLimitHeaders.Polly | ✅ | ✅ | ✅ |
Contributing
We welcome contributions! Whether it's bug reports, feature requests, documentation improvements, or code contributions.