implementing-api-rate-limiting-and-throttling

Featured

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.

API & Backend 36,355 stars 4443 forks Updated 2 months ago Apache-2.0

Install

View on GitHub

Quality Score: 94/100

Stars 20%
100
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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": {"reques...

Details

Author
mukul975
Repository
mukul975/Anthropic-Cybersecurity-Skills
Created
8 months ago
Last Updated
2 months ago
Language
Python
License
Apache-2.0

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category