
Api Rate Limiting
This covers the three main rate limiting algorithms you'll actually use: token bucket for smooth traffic shaping, sliding window for precision, and fixed window when you need something simple. The reference guides include Redis implementations, which is what you want for any production system that runs on multiple servers. It also handles the tiered limits scenario, so you can give paying customers higher quotas. The code examples are JavaScript and Python/Flask, and it reminds you to include the standard rate limit headers in responses. One thing to know: the best practices correctly warn against in-memory storage in production, but the quick start example is in-memory, so you'll need to jump to the Redis guide for real deployments.
- skills.sh installs
- 647
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill api-rate-limiting --agent claude-codeInstalls into .claude/skills of the current project.
Files
API Rate Limiting
Table of Contents
Overview
Protect APIs from abuse and manage traffic using various rate limiting algorithms with per-user, per-IP, and per-endpoint strategies.
When to Use
- Protecting APIs from brute force attacks
- Managing traffic spikes
- Implementing tiered service plans
- Preventing DoS attacks
- Fairness in resource allocation
- Enforcing quotas and usage limits
Quick Start
Minimal working example:
// Token Bucket Rate Limiter
class TokenBucket {
constructor(capacity, refillRate) {
this.capacity = capacity;
this.tokens = capacity;
this.refillRate = refillRate; // tokens per second
this.lastRefillTime = Date.now();
}
refill() {
const now = Date.now();
const timePassed = (now - this.lastRefillTime) / 1000;
const tokensToAdd = timePassed * this.refillRate;
this.tokens = Math.min(this.capacity, this.tokens + tokensToAdd);
this.lastRefillTime = now;
}
consume(tokens = 1) {
this.refill();
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Backend & APIs, AI & Agent Building, Marketing & SEO
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Internationalization I18n642
- Information Architecture641
- Backup Disaster Recovery626
- Github Actions Workflow626
- Color Accessibility624
- Fastapi Development624
- Static Code Analysis622
- Unit Testing Framework622
- Aws Lambda Functions619
- User Research Analysis618
- Vulnerability Scanning617
- Data Encryption616
- Api Authentication612
- Performance Testing609
- Competitor Analysis608
- Refactor Legacy Code608
- Security Testing607
- Frontend Accessibility604
- Design Patterns Implementation600
- Database Schema Design597
- Aws S3 Management595
- Database Query Optimization593
- Memory Leak Detection589
- Database Backup Restore588