--- id: pyrate-limiter version: "4.4.0" license: MIT license_treatment: permissive maintenance: active --- # pyrate-limiter — Python Rate-Limiter using Leaky-Bucket Algorithm License: permissive · Maintenance: active · Downloads: 7.9M/mo ## What it is and what it does PyrateLimiter is a rate-limiting library that enforces request quotas using the Leaky-Bucket algorithm. It allows you to define multiple simultaneous rate limits (e.g., 5 per second and 1000 per hour) on the same key, and routes each key to a bucket that tracks and throttles incoming requests. The library works in both sync and async contexts, offering blocking (wait for a permit), non-blocking (fail fast), and timeout-based acquisition modes. The package supports multiple storage backends: in-memory buckets for single-process use, SQLite for persistence, Redis (sync and async) for distributed systems, Postgres for shared state, and multiprocessing for worker pools. You can use it directly via `try_acquire()` calls, as a decorator on functions, or as a context manager. The same API works identically in sync and async code paths without blocking the event loop. Use it for: - Enforce API rate limits on web services (e.g., 100 requests per minute per user) - Throttle background job workers to avoid overwhelming downstream services - Distribute rate limits across multiple processes or machines using Redis or Postgres - Implement per-resource quotas in multi-tenant applications with independent tracking - Decorate async functions to prevent concurrent request spikes without blocking ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. PyrateLimiter implements the Leaky-Bucket rate-limiting algorithm with support for multiple simultaneous rate limits, pluggable backends (in-memory, SQLite, Redis, Postgres, multiprocessing), and both sync and async APIs. Yes. PyrateLimiter is a mature, well-maintained library with zero known vulnerabilities, no runtime dependencies, and permissive licensing. It solves a common problem (rate limiting) with a clean API that works seamlessly in both sync and async code. Install it if you need to enforce request quotas or throttle access to resources. ## Install pip install pyrate-limiter uv add pyrate-limiter poetry add pyrate-limiter ## Installing pyrate-limiter Before you install: Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release (61 days ago) and 512 repository stars. Supports Python 3.10 through 3.14. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations. Quickstart: pip install pyrate-limiter from pyrate_limiter import Duration, Rate, Limiter limiter = Limiter(Rate(5, Duration.SECOND * 2)) limiter.try_acquire("my-resource") Requires Python 3.10 or later. Verify before relying: - Performance characteristics under high concurrency or with large numbers of keys - Behavior and overhead of each backend option (in-memory vs. Redis vs. Postgres) at scale - Exact semantics of the leaking mechanism and background cleanup scheduling ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 7.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags rate limiter python, leaky bucket algorithm, async rate limiting, request throttling, per-key rate limits, redis rate limiter, api quota enforcement, rate-limiting, async-friendly, distributed [View on SkillFed](https://skillfed.io/packages/pyrate-limiter) · [View on PyPI](https://pypi.org/project/pyrate-limiter/)