Skip to main content

Consume any API with no ratelimit breach, patient mode 💤

Project description

AsyncApiThrottler README

AsyncApiThrottler is a Python library designed for managing API request rate limits in asynchronous applications. It allows you to easily configure global and endpoint-specific rate limits, ensuring your application adheres to the API's rate limiting policies and prevents being blocked or rate-limited. This README provides a quick start example on how to use AsyncApiThrottler with httpx for making asynchronous API requests.

Quick Start Example

import httpx
from async_api_throttler import AsyncApiThrottler

# Initialize the throttler with a global rate limit
api_throttler = AsyncApiThrottler(max_calls=100, period=1)

# Apply endpoint-specific rate limits using the decorator
@api_throttler.limits(10, 1)
async def request_user_endpoint():
    # Make an asynchronous API request using httpx
    async with httpx.AsyncClient() as client:
        response = await client.get('https://api.example.com/user')
        return response.json()

This example demonstrates how to set up AsyncApiThrottler with a global limit of 100 requests per minute and a specific rate limit of 10 requests per minute for the '/user' endpoint. By integrating AsyncApiThrottler in this way, you ensure your application respects the API's rate limits, promoting efficient and responsible usage of resources.

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

async_api_throttler-0.2.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

async_api_throttler-0.2.0-py3-none-any.whl (4.3 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