disagreement/docs/rate_limiter.md
Slipstream a13cf1e4f8
Some checks failed
Deploy MkDocs / deploy (push) Has been cancelled
docs: sync with codebase (#65)
2025-06-11 17:09:23 -06:00

15 lines
587 B
Markdown

# Rate Limiter
The HTTP client uses an asynchronous `RateLimiter` to respect Discord's per-route and global rate limits. Each request acquires a bucket associated with the route. The limiter delays requests when the bucket is exhausted and handles global rate limits automatically.
```python
from disagreement.rate_limiter import RateLimiter
rl = RateLimiter()
bucket = await rl.acquire("GET:/channels/1")
# perform request
rl.release("GET:/channels/1", response_headers)
```
`handle_rate_limit(route, retry_after, is_global)` can be used when the API returns a rate limit response.