Skip to content

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: Works with ASGI (FastAPI) and WSGI (Flask, Django) environments.
  • 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

pip install pycurb
pip install "pycurb[redis]"
pip install "pycurb[fastapi]"
pip install "pycurb[django]"
pip install "pycurb[flask]"
pip install "pycurb[all]"

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 →

Production‑Ready

  • Type-safe: Fully annotated with type hints for better IDE support.
  • Tested: Comprehensive test suite with broad coverage.
  • Benchmarked: Performance-tested across algorithms and storage backends.
  • Documented: Extensive documentation with practical examples.

License

PyCurb is released under the Apache License 2.0.

Built by the PyCurb team  ·  GitHub  ·  Changelog