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

587 B

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.

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.