RateLimitHeaders
Parse IETF RateLimit headers for proactive rate limit awareness in .NET HttpClient and Polly pipelines.
Install / Use
/learn @Alos-no/RateLimitHeadersREADME
RateLimitHeaders
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
Packages
| 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
Example
// 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();
Features
-
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
Get Started
<div align="center">📚 Ready to dive in?
Explore the Full Documentation →
Comprehensive guides, configuration options, custom algorithms, and more.
</div>Supported Frameworks
| Package | .NET 8 | .NET 9 | .NET 10 | |---------|:------:|:------:|:-------:| | RateLimitHeaders | Yes | Yes | Yes | | RateLimitHeaders.Polly | Yes | Yes | Yes |
Contributing
We welcome contributions! Whether it's bug reports, feature requests, or code contributions.
License
This project is licensed under the MIT License.
Related Projects
- Polly - The .NET resilience library
- Microsoft.Extensions.Http.Resilience - Official Polly integration for HttpClient
Related Skills
node-connect
348.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
