Skip to main content

Enhance Your Calm - Advanced Rate Limiting & DDoS Protection for FastAPI

Project description

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

Cybersecurity Projects Python License: AGPLv3 PyPI FastAPI

Production 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="100/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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_420-1.0.1.tar.gz (161.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_420-1.0.1-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_420-1.0.1.tar.gz.

File metadata

  • Download URL: fastapi_420-1.0.1.tar.gz
  • Upload date:
  • Size: 161.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastapi_420-1.0.1.tar.gz
Algorithm Hash digest
SHA256 39def7702248018edff86f2b82cf7006277f85346ff8f01448518089642dbbac
MD5 9c845f87855dbbf69d18365f28433ded
BLAKE2b-256 10b49fee3869209afb0a5c394cc0f1dbb32888c887ed632d500e4587d39c6e9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_420-1.0.1.tar.gz:

Publisher: publish-api-rate-limiter.yml on CarterPerez-dev/Cybersecurity-Projects

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_420-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fastapi_420-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastapi_420-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d0e36cfc531214d7d7588fcae2851bdfcb35005d310cd6bf6fd2750fac059bb
MD5 2fd75f08b73d2e54566ebd1eb4c58a4d
BLAKE2b-256 f673a40a8fb154fb5968739ac04baeb29bd1924cfba0c5ce698902e48681e402

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_420-1.0.1-py3-none-any.whl:

Publisher: publish-api-rate-limiter.yml on CarterPerez-dev/Cybersecurity-Projects

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page