Asynchronous library for easy requests to APIs with any rate limits, with support for token rotation.
aiorotation simplifies making async API requests while automatically respecting rate limits and rotating tokens when they reach their usage quota.
Perfect for free or public APIs that restrict per-token or per-minute requests.
When a token hits its rate limit, aiorotation automatically switches to the next available one, ensuring continuous operation without API errors.
- ⚡ Async-first — designed around
asyncio - 🔁 Token rotation — automatic switching between API keys
- ⏱️ Rate limiting — supports all RPS, RPM, RPH, RPD and even custom limits
- 🪶 Zero dependencies — clean and lightweight
pip install aiorotationfrom aiorotation import Rotator, Limit
rotator = Rotator(
tokens=['token1', 'token2', 'token3'], # you can use rotator without tokens
# rps=1,
rpm=30,
# limits=[
# Limit(120, 60) # custom limit 60 requests per 120 seconds (2 minutes)
# ]
)
async with rotator.acquire() as token:
print('Using token:', token)
await api_request(token, ...)MIT License © 2025 Creeper Hack See the LICENSE file for details.
- 🐙 GitHub: github.com/creehk/aiorotation
- 📦 PyPI: pypi.org/project/aiorotation
- Rotating tokens for free APIs (like Gemini, OpenAI, or weather APIs)
- Handling multiple accounts or API keys efficiently
- Building rate-limit-safe crawlers or data fetchers
- Managing multiple access tokens for distributed microservices