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 Njones17
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/njones17-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, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/implementing-api-rate-limiting-and-throttling
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
- MIT
- Instructions
- 450 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
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 Njones17/AI-agent-master-cyber-skills-list, MIT.
More from Njones17/AI-agent-master-cyber-skills-list
- 0.497score
integrating-dast-with-owasp-zap-in-pipeline
Njones17
This skill covers integrating OWASP ZAP (Zed Attack Proxy) for Dynamic Application Security Testing in CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
dast-scanning
devops-skills
Perform dynamic application security testing with OWASP ZAP, Burp Suite, and Nikto.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
performing-sca-dependency-scanning-with-snyk
Njones17
This skill covers implementing Software Composition Analysis (SCA) using Snyk to detect vulnerable open-source dependencies in CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
integrating-sast-into-github-actions-pipeline
Njones17
This skill covers integrating Static Application Security Testing (SAST) tools—CodeQL and Semgrep—into GitHub Actions CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
ghost-scan-code
Njones17
Ghost Security - SAST code scanner.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
sast-scanning
devops-skills
Perform static application security testing with tools like Semgrep, CodeQL, and SonarQube.
SkillDFreshness: D★ 24Claude Code +9 - 0.494score
implementing-github-advanced-security-for-code-scanning
Njones17
Configure GitHub Advanced Security with CodeQL to perform automated static analysis and vulnerability detection across repositories at enterprise scale.
SkillDFreshness: D★ 24Claude Code +9 - 0.494score
performing-cryptographic-audit-of-application
Njones17
A cryptographic audit systematically reviews an application's use of cryptographic primitives, protocols, and key management to identify vulnerabilities such…
SkillDFreshness: D★ 24Claude Code +9 - 0.494score
implementing-semgrep-for-custom-sast-rules
Njones17
Write custom Semgrep SAST rules in YAML to detect application-specific vulnerabilities, enforce coding standards, and integrate into CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.492score
implementing-api-key-security-controls
Njones17
Implements secure API key generation, storage, rotation, and revocation controls to protect API authentication credentials from leakage, brute force, and abuse.
SkillDFreshness: D★ 24Claude Code +9 - 0.492score
implementing-api-gateway-security-controls
Njones17
Implements security controls at the API gateway layer including authentication enforcement, rate limiting, request validation, IP allowlisting, TLS…
SkillDFreshness: D★ 24Claude Code +9 - 0.492score
ghost-repo-context
Njones17
Scans directory structure, detects projects, maps dependencies, and documents code organization into a repo.md file.
SkillDFreshness: D★ 24Claude Code +9
Signals
- Stars
- 24
- Forks
- 6
- Open issues
- 0
- Last commit (this folder)
- Mar 6, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- 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 Njones17
- 0.497score
ghost-scan-code
Njones17
Ghost Security - SAST code scanner.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
integrating-sast-into-github-actions-pipeline
Njones17
This skill covers integrating Static Application Security Testing (SAST) tools—CodeQL and Semgrep—into GitHub Actions CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
integrating-dast-with-owasp-zap-in-pipeline
Njones17
This skill covers integrating OWASP ZAP (Zed Attack Proxy) for Dynamic Application Security Testing in CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.497score
performing-sca-dependency-scanning-with-snyk
Njones17
This skill covers implementing Software Composition Analysis (SCA) using Snyk to detect vulnerable open-source dependencies in CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.494score
implementing-semgrep-for-custom-sast-rules
Njones17
Write custom Semgrep SAST rules in YAML to detect application-specific vulnerabilities, enforce coding standards, and integrate into CI/CD pipelines.
SkillDFreshness: D★ 24Claude Code +9 - 0.494score
implementing-github-advanced-security-for-code-scanning
Njones17
Configure GitHub Advanced Security with CodeQL to perform automated static analysis and vulnerability detection across repositories at enterprise scale.
SkillDFreshness: D★ 24Claude Code +9
Cite this page
implementing-api-rate-limiting-and-throttling skill. Agent Mart. https://agentmart.dev/skills/njones17-implementing-api-rate-limiting-and-throttling (last updated 2026-10-24)