Skip to main content

Makes it easy to respect rate limits.

Project description

Ratelim is a simple Python library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.


  • Works in Py2 and Py3.
  • Greedy and patient rate limiting.
  • Preserves function signature.


$ pip install ratelim


Say you want to call a function at most for n_calls during a n_seconds time interval.

# 10 times in 5 seconds
@ratelim.greedy(10, 5)
def hello():

The greedy rate limiter calls does not delay any function call until it’s really necessary.

In some scenarios, for example when crawling data from an API, you want to maximize the number of calls you make and you want to avoid sending them in short sequence. To this aim, we can use the patient rate limiter. It distributes calls evenly between each other.

# 10 times in 5 seconds
# Gets called at most every 0.5 seconds
@ratelim.patient(10, 5)
def hello():



Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
ratelim-0.1.6-py2.py3-none-any.whl (4.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3
ratelim-0.1.6.tar.gz (2.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page