Check if a request is allowed without consuming tokens
Unique identifier for the rate limit (e.g., user ID, agent ID)
Rate limit result
Reset the rate limit for a specific key
Unique identifier for the rate limit
Get current state for a key without modifying it
Unique identifier for the rate limit
Current rate limit state, or null if no state exists
Block a key from making requests for a duration
Unique identifier to block
Duration to block in milliseconds
Unblock a previously blocked key
Unique identifier to unblock
Check if a key is currently blocked
Unique identifier to check
true if blocked
Clear all buckets (useful for testing)
Get number of tracked keys
Token bucket rate limiter implementation.
Uses the token bucket algorithm to provide smooth rate limiting. Tokens are added at a constant rate, and each request consumes tokens.
Features:
Example