--- id: ratelimit version: "2.2.1" license: MIT license_treatment: permissive maintenance: active --- # ratelimit — API rate limit decorator License: permissive · Maintenance: active · Downloads: 12.7M/mo ## What it is and what it does ratelimit is a simple decorator-based rate limiter for Python functions that make API calls. It enforces a maximum number of function invocations within a specified time period (defaulting to 15 minutes), raising a RateLimitException when the quota is exceeded. This helps prevent applications from violating API provider rate limits and getting banned. The package provides two strategies for handling rate-limit violations: raising an exception (which you can catch and retry), or using the sleep_and_retry decorator to automatically pause the current thread until the time window resets before retrying. It has no runtime dependencies and works by wrapping any function with a simple @limits(calls=N, period=seconds) decorator. Use it for: - Wrap API client functions to enforce a 15 minute rate limit or any custom quota without manual tracking - Combine with retry logic to implement automatic retry when rate limits are hit - Ensure background jobs or data-sync tasks respect API provider rate limits without explicit delay management - Protect against accidental API abuse by adding a decorator to functions that call rate-limited endpoints ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A function decorator that enforces rate limits on API calls, raising an exception or sleeping to prevent exceeding a specified call quota within a time window. Yes, with caution. The package is simple, stable, and solves a real problem for API-heavy applications. However, the lack of updates since 2018-12-17 is a significant concern—verify compatibility with your Python version before relying on it in production. For straightforward rate-limiting needs, this remains functional. ## Install pip install ratelimit uv add ratelimit poetry add ratelimit ## Installing ratelimit Before you install: High install friction; the package has not been updated since 2018-12-17, over 2797 days ago. While the repository remains active and marked stable, the age of the latest release may indicate limited responsiveness to compatibility issues. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions, though you must include the license notice. Quickstart: pip install ratelimit from ratelimit import limits FIFTEEN_MINUTES = 900 @limits(calls=15, period=FIFTEEN_MINUTES) def call_api(url): response = requests.get(url) return response No runtime dependencies, but requires an external HTTP library (e.g. requests) for the decorated function to work. Verify before relying: - Compatibility with current Python versions (requires_python is unspecified) - Whether the package works correctly with modern async frameworks - Active community support or response time for bug reports given the 2018 release date ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: high - Maintenance: active - Downloads: 12.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags rate limit decorator, api call throttling, prevent rate limit violations, function call frequency limiter, api quota enforcement, throttle function calls, rate limiting decorator python, api-throttling, decorator, legacy-stable [View on SkillFed](https://skillfed.io/packages/ratelimit) · [View on PyPI](https://pypi.org/project/ratelimit/)