Uprate is a robust, simple ratelimit library.
While providing a simple to use api, it is also highly scalable
and provides absolute control for fine-tuning.
Hence, Uprate
can be used in all stages of your app from prototyping to production! 🚀
Here is a simple example.
There are two ways ratelimits are implemented in python for server-side
- Make everything from scratch
- Use a framework dependent ratelimit library.
The problem in the first way is obvious, it's harder, consumes more time.
Using a framework dependent ratelimit library is more feasible, but often
these libraries don't provide features like external stores, multiple ratelimits
and manual key specification. While there are some awesome ratelimit libraries for
framwork X, not everyone uses framework X 😕.
Ratelimits in client-sided coded also face similar problems. Often APIs enforce multiple ratelimits. Making a ratelimiter from scratch for your API wrapper or a small scale data collector takes up valuable dev time, which is why uprate aims to also provide tools for client-sided code.
The documentation can be found at https://uprate.readthedocs.io/en/latest/
You can install the latest stable version from pypi by
pip install uprate
or you can install the dev version from github
pip install git+https://github.com/WizzyGeek/uprate.git@master#egg=uprate
import uprate
And you are good to go! 🤘
Here is a simple example that demonstrates Uprate's Awesomeness.
import uprate
@uprate.ratelimit(1 / (uprate.Seconds(2) + uprate.Minutes(1)))
def limited():
...
limited()
try:
# Within 62 seconds
limited()
except uprate.RateLimitError:
print("called function too fast")
And so much more!