Cybersecurity-Projects/PROJECTS/advanced/api-rate-limiter
Carter Perez e9533cdd4d
Merge pull request #229 from CarterPerez-dev/dependabot/uv/PROJECTS/advanced/api-rate-limiter/urllib3-2.7.0
chore(deps): bump urllib3 from 2.6.3 to 2.7.0 in /PROJECTS/advanced/api-rate-limiter
2026-05-13 02:42:27 -04:00
..
examples feat: did a couple things idk 2026-02-28 14:08:36 -05:00
learn Update 00-OVERVIEW.md 2026-02-20 02:19:33 -05:00
src/fastapi_420 feat: did a couple things idk 2026-02-28 14:08:36 -05:00
tests feat: did a couple things idk 2026-02-28 14:08:36 -05:00
.style.yapf Phase 1.1: Organize PROJECTS by difficulty level 2026-01-29 02:41:15 -05:00
LICENSE - Standardize READMEs and add justfiles across all 14 projects 2026-02-11 07:01:25 -05:00
README.md Update README with new Python version and rate limit 2026-02-11 07:43:44 -05:00
justfile - Standardize READMEs and add justfiles across all 14 projects 2026-02-11 07:01:25 -05:00
pyproject.toml issue 77 2026-02-18 18:53:15 -05:00
uv.lock Merge pull request #229 from CarterPerez-dev/dependabot/uv/PROJECTS/advanced/api-rate-limiter/urllib3-2.7.0 2026-05-13 02:42:27 -04:00

README.md

███████╗ █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗     ██╗  ██╗██████╗  ██████╗
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║     ██║  ██║╚════██╗██╔═████╗
█████╗  ███████║███████╗   ██║   ███████║██████╔╝██║     ███████║ █████╔╝██║██╔██║
██╔══╝  ██╔══██║╚════██║   ██║   ██╔══██║██╔═══╝ ██║     ╚════██║██╔═══╝ ████╔╝██║
██║     ██║  ██║███████║   ██║   ██║  ██║██║     ██║          ██║███████╗╚██████╔╝
╚═╝     ╚═╝  ╚═╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝     ╚═╝          ╚═╝╚══════╝ ╚═════╝

Cybersecurity Projects Python License: AGPLv3 PyPI FastAPI

Enterprise rate limiting for FastAPI using HTTP 420 "Enhance Your Calm".

This is a quick overview — security theory, architecture, and full walkthroughs are in the learn modules.

What It Does

  • Three implementation methods: middleware (global), decorator (per route), dependency injection
  • Sliding Window, Token Bucket, and Fixed Window rate limiting algorithms
  • Redis support with automatic in-memory fallback when Redis is unavailable
  • Scoped rate limiters for applying different limits to endpoint groups
  • Fingerprint levels (RELAXED, NORMAL, STRICT) for client identification granularity
  • Multiple stacking rules where the most restrictive limit applies

Quick Start

uv add fastapi-420
from fastapi import FastAPI
from fastapi_420 import RateLimiter, RateLimiterSettings

app = FastAPI()
limiter = RateLimiter(RateLimiterSettings(default_limit="69/minute"))
app.add_middleware(limiter.middleware)

For Redis support: uv add fastapi-420[redis]

[!TIP] This project uses just as a command runner. Type just to see all available commands.

Install: curl -sSf https://just.systems/install.sh | bash -s -- --to ~/.local/bin

Learn

This project includes step-by-step learning materials covering security theory, architecture, and implementation.

Module Topic
00 - Overview Prerequisites and quick start
01 - Concepts Security theory and real-world breaches
02 - Architecture System design and data flow
03 - Implementation Code walkthrough
04 - Challenges Extension ideas and exercises

License

AGPL 3.0