Coder Social home page Coder Social logo

wizzygeek / uprate Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 197 KB

RateLimits. Dumbified. Simple to use, fast, intuitive rate limit lib with async and sync support for python!

Home Page: https://uprate.readthedocs.io/en/latest/

License: MIT License

Python 100.00%
rate-limiting ratelimter python3 typed flexible

uprate's Introduction

A fully typed, simple ratelimit library.


About

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.

Why?

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/

Getting Started

Installation

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

Usage

import uprate

And you are good to go! ๐Ÿค˜

Example

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!

Thanks to @someonetookmycode for the graphical assets
ยฉ WizzyGeek 2021

uprate's People

Contributors

actions-user avatar wizzygeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

uprate's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.