implementing-api-rate-limiting-and-throttling
Implements API rate limiting and throttling controls using token bucket, sliding window, and fixed window algorithms to protect against brute force attacks…
Skill by pinkpixel-dev
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/pinkpixel-dev-implementing-api-rate-limiting-and-throttling
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
implementing-api-rate-limiting-and-throttling- Description
- Implements API rate limiting and throttling controls using token bucket, sliding window, and fixed window algorithms to protect against brute force attacks, credential stuffing, resource exhaustion, and API abuse. The engineer configures per-user, per-IP, and per-endpoint rate limits using Redis-backed counters, API gateway plugins, or application middleware, and implements proper HTTP 429 responses with Retry-After headers. Activates for requests involving rate limiting implementation, API throttling setup, request quota management, or API abuse prevention.
- License
- Apache-2.0
- Instructions
- 450 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (4)
- LICENSE
- SKILL.md
- api-reference.md · references/
- agent.py · scripts/
SKILL.md (first lines)
# Implementing API Rate Limiting and Throttling
## When to Use
- Protecting authentication endpoints against brute force and credential stuffing attacks
- Preventing API abuse and resource exhaustion from automated scripts and bots
- Implementing fair usage quotas for different API consumer tiers (free, premium, enterprise)
- Defending against denial-of-service attacks at the application layer
- Meeting compliance requirements that mandate API abuse prevention controls
**Do not use** rate limiting as the sole defense against attacks. Combine with authentication, authorization, and WAF rules.
## Prerequisites
- Redis 6.0+ for distributed rate limit counters (or in-memory for single-instance deployments)
- API framework (Express.js, FastAPI, Spring Boot, or Django REST Framework)
- Monitoring system for rate limit metrics (Prometheus, CloudWatch, Datadog)
- Understanding of the API's normal traffic patterns and peak usage
- Load testing tool (k6, Gatling, or Locust) for validating rate limit behavior
## Workflow
### Step 1: Rate Limiting Strategy Design
Define rate limits per endpoint category and user tier:
```python
# Rate limit configuration
RATE_LIMITS = {
# Authentication endpoints (most restrictive)
"auth": {
"login": {"requests": 5, "window_seconds": 60, "by": "ip"},
"register": {"requests": 3, "window_seconds": 300, "by": "ip"},
"forgot_password": {"requests": 3, "window_seconds": 3600, "by": "ip"},
"verify_mfa": {"requests": 5, "window_seconds": 300, "by": "user"},
},
# Standard API endpoints
"api": {
"free": {"requests": 60, "window_seconds": 60, "by": "user"},
"premium": {"requests": 300, "window_seconds": 60, "by": "user"},
"enterprise": {"requests": 1000, "window_seconds": 60, "by": "user"},
},
# Resource-intensive endpoints
"expensive": {
"search": {"requests": 10, "window_seconds": 60, "by": "user"},
"export": {"requests": 5, "window_seconds": 3600, "by": "user"},
"bulk_import": {"requests": 2, "window_seconds": 3600, "by": "user"},
},
# Global limits
"global": {
"per_ip": {"requests": 1000, "window_seconds": 60, "by": "ip"},
"per_user": {"requests": 5000, "window_seconds": 3600, "by": "user"},
},
}
```
### Step 2: Sliding Window Rate Limiter (Redis)
```python
import redis
import time
import hashlib
from functools import wraps
from flask import Flask, request, jsonify, g
app = Flask(__name__)
redis_client = redis.Redis(host='localhost', port=6379, db=0, decode_responses=True)
class SlidingWindowRateLimiter:
"""Sliding window rate limiter using Redis sorted sets."""
def __init__(self, redis_conn):
self.redis = redis_conn
def is_allowed(self, key, max_requests, window_seconds):
"""Check if request is allowed and record it."""
now = time.time()
window_start = now - window_seconds
pipe = self.redis.pipeline()
# Remove expired entries
pipe.zremrangebyscore(key, 0, window_start)
# Count requests in current window
pipe.zcard(key)
# Add current request
pipe.zadd(key, {f"{now}:{hashlib.md5(str(now).encode()).hexdigest()[:8]}": now})
# Set TTL on the key
pipe.expire(key, window_seconds + 1)
results = pipe.execute()
current_count = results[1]
if current_count >= max_requests:
# Calculate retry-after
oldest = self.redis.zrange(key, 0, 0, withscores=True)
if oldest:
retry_after = int(oldest[0][1] + window_seconds - now) + 1
else:
retry_after = window_seconds
return False, current_count, max_requests, retry_after
return True, current_count + 1, max_requests, 0
rate_limiter = SlidingWindowRateLimiter(redis_client)
def rate_limit(max_requests, window_seconds, key_func=None):
"""Decorator for rate limiting API endpoints."""
def decorator(f):
@wraps(f)
def wrapped(*args, **kwargs):
# Determine the rate limit key
if key_func:
identifier = key_func()
elif hasattr(g, 'user_id'):
identifier = f"user:{g.user_id}"
else:
identifier = f"ip:{request.remote_addr}"
key = f"ratelimit:{request.endpoint}:{identifier}"
allowed, current, limit, retry_after = rate_limiter.is_allowed(From pinkpixel-dev/skills-collection-2, Apache-2.0.
More from pinkpixel-dev/skills-collection-2
- 0.459score
implementing-alert-fatigue-reduction
pinkpixel-dev
Implements strategies to reduce SOC alert fatigue by tuning detection rules, consolidating duplicate alerts, implementing risk-based alerting, and measuring…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-application-whitelisting-with-applocker
pinkpixel-dev
Implements application whitelisting using Windows AppLocker to restrict unauthorized software execution on endpoints, reducing attack surface from malware…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-attack-surface-management
pinkpixel-dev
Implements external attack surface management (EASM) using Shodan, Censys, and ProjectDiscovery tools (subfinder, httpx, nuclei) for asset discovery…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-aws-nitro-enclave-security
pinkpixel-dev
Implements AWS Nitro Enclave-based confidential computing environments with cryptographic attestation, KMS policy integration using PCR-based condition keys…
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-aws-macie-for-data-classification
pinkpixel-dev
Implement Amazon Macie to automatically discover, classify, and protect sensitive data in S3 buckets using machine learning and pattern matching for PII…
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-attack-path-analysis-with-xm-cyber
pinkpixel-dev
Deploy XM Cyber's continuous exposure management platform to map attack paths, identify choke points, and prioritize the 2% of exposures that threaten…
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-aes-encryption-for-data-at-rest
pinkpixel-dev
AES (Advanced Encryption Standard) is a symmetric block cipher standardized by NIST (FIPS 197) used to protect classified and sensitive data.
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-aws-config-rules-for-compliance
pinkpixel-dev
Implementing AWS Config rules for continuous compliance monitoring of AWS resources, deploying managed and custom rules aligned to CIS and PCI DSS frameworks…
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-aws-iam-permission-boundaries
pinkpixel-dev
Configure IAM permission boundaries in AWS to delegate role creation to developers while enforcing maximum privilege limits set by the security team.
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-anti-phishing-training-program
pinkpixel-dev
Security awareness training is the human layer of phishing defense.
SkillDFreshness: D★ 4Claude Code +9 - 0.456score
implementing-aqua-security-for-container-scanning
pinkpixel-dev
Deploy Aqua Security's Trivy scanner to detect vulnerabilities, misconfigurations, secrets, and license issues in container images across CI/CD pipelines and…
SkillDFreshness: D★ 4Claude Code +9 - 0.455score
implementing-anti-ransomware-group-policy
pinkpixel-dev
Configures Windows Group Policy Objects (GPO) to prevent ransomware execution and limit its spread.
SkillDFreshness: D★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Mar 29, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from pinkpixel-dev
- 0.534score
adhd
pinkpixel-dev
Parallel divergent ideation for coding agents.
SkillCFreshness: C★ 9Claude Code +9 - 0.470score
3d-web-experience
pinkpixel-dev
You bring the third dimension to the web.
SkillDFreshness: D★ 9Claude Code +9 - 0.459score
implementing-aws-nitro-enclave-security
pinkpixel-dev
Implements AWS Nitro Enclave-based confidential computing environments with cryptographic attestation, KMS policy integration using PCR-based condition keys…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-attack-surface-management
pinkpixel-dev
Implements external attack surface management (EASM) using Shodan, Censys, and ProjectDiscovery tools (subfinder, httpx, nuclei) for asset discovery…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-application-whitelisting-with-applocker
pinkpixel-dev
Implements application whitelisting using Windows AppLocker to restrict unauthorized software execution on endpoints, reducing attack surface from malware…
SkillDFreshness: D★ 4Claude Code +9 - 0.459score
implementing-alert-fatigue-reduction
pinkpixel-dev
Implements strategies to reduce SOC alert fatigue by tuning detection rules, consolidating duplicate alerts, implementing risk-based alerting, and measuring…
SkillDFreshness: D★ 4Claude Code +9
Cite this page
implementing-api-rate-limiting-and-throttling skill. Agent Mart. https://agentmart.dev/skills/pinkpixel-dev-implementing-api-rate-limiting-and-throttling (last updated 2026-10-24)