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
Built Distribution
File details
Details for the file async_api_throttler-0.2.0.tar.gz
.
File metadata
- Download URL: async_api_throttler-0.2.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3048a3771d77bed51567dae02a0edba9de9396c04a54850143a86162cbfa98cf |
|
MD5 | a8ebbc3f0f85394b2a1bfd1692d2a6b8 |
|
BLAKE2b-256 | e521517c8fd33ce900cabe182e665b0cc8cb27b5dae66f2a65edcccd7e2ce500 |
File details
Details for the file async_api_throttler-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: async_api_throttler-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4154a1f303d5747c5c220614e609d4b7dee45fce154da1795ee69d3ad200d8e7 |
|
MD5 | 4ad7f09a9cd9697b4e858106dce4818d |
|
BLAKE2b-256 | 77a34dc42821c021914485efc1581996f4e27940879a32840aa7bee8251b6b22 |