PyCurb¶
Framework-agnostic rate limiting for Python¶
PyCurb is a rate-limiting library that works with FastAPI, Flask, Django, and general Python applications. Choose from five algorithms, pluggable storage backends, and framework adapters — all via a simple, consistent API.
Why PyCurb?¶
- Five algorithms: Sliding Window, Fixed Window, Token Bucket, Leaky Bucket, and GCRA — choose the right strategy for your workload.
- Async & sync: Supports async FastAPI and Django views, plus sync Flask and Django integrations.
- Pluggable storage: In-memory and Redis backends with graceful fallback and connection pooling.
- Framework adapters: Ready-to-use adapters for FastAPI, Flask, and Django — minimal integration code.
- Composite limits: Enforce multiple rules simultaneously (for example, per-minute + per-hour) with a single check.
- High performance: Minimal overhead and optimized for production workloads.
Installation¶
What Next?¶
Getting Started
Install PyCurb and write a rate-limited endpoint in minutes.
Learn More →
Algorithms
Learn about the five rate-limiting strategies and recommended use cases.
Learn More →
Framework adapters
Quick integrations for FastAPI, Flask, and Django.
Learn More →Quality¶
- Type-safe: Fully annotated with type hints (PEP 561
py.typedmarker) for better IDE support. - Tested: Comprehensive test suite across algorithms, storage backends, and adapters, run on Linux, macOS, and Windows with Python 3.10–3.14.
- Benchmarked: Performance-tested across algorithms and storage backends.
- Documented: Extensive documentation with practical examples.
License¶
PyCurb is released under the Apache License 2.0.