Implement rate limiting for APIs to prevent abuse
# API Rate Limiting
## Rate Limiting Algorithms
- Token bucket algorithm
- Sliding window log
- Fixed window counters
- Leaky bucket pattern
## Implementation
- Use Redis for distributed limiting
- Set appropriate limits
- Return proper headers
- Implement user-specific limits
## Response Headers
- X-RateLimit-Limit
- X-RateLimit-Remaining
- X-RateLimit-Reset
- Retry-After on 429
## Best Practices
- Rate limit by IP and user
- Implement exponential backoff
- Monitor rate limit hits
- Provide clear error messagesThis API prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their api implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For API projects, consider mentioning your framework version, coding style, and any specific libraries you're using.