Skip to content

creehk/aiorotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiorotation

PyPI version Python License GitHub stars


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.


✨ Features

  • 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

📦 Installation

pip install aiorotation

🚀 Example

from 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, ...)

📄 License

MIT License © 2025 Creeper Hack See the LICENSE file for details.


🔗 Links


💡 Example Use Cases

  • 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

About

Asynchronous library for easy requests to APIs with any rate limits, with support for token rotation.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages