Skip to main content

API rate limit decorator

Project description

Api_Limit

About

It's Simple Middeleware implemented with tocken bucket algorithm to manage the number of api per seconds.

Usage

import time
from api_limit import api_limit
import requests

@api_limit(max_api_call=2)
def call_api(url):
    response = requests.get(url)
    if response.status_code != 200:
        raise Exception('API response: {}'.format(response.status_code))
    return response

We can also specify wheter overflow of call should return the response or simply avoide the call without acknowledgement.

Project details


Download files

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

Source Distribution

api_limit-0.0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

api_limit-0.0.2-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page