An async Python wrapper for the DonutSMP API with full type safety using Pydantic models.
pip install donutsmp-apiimport asyncio
from donut import DonutClient
async def main():
async with DonutClient("your-api-key") as client:
stats = await client.stats("archivepedro")
print(stats)
asyncio.run(main())- Fully async with
aiohttp - Type-safe responses via Pydantic models
- Built-in rate limiting (configurable)
- Support for multiple API keys (automatic rotation)
client = DonutClient(
api_keys="key", # Single key or list of keys
timeout=30.0, # Request timeout in seconds
requests_per_minute=250 # Rate limit per key
)# Single lookup
stats = await client.stats("username")
# Batch lookup
stats_list = await client.stats.batch(["user1", "user2", "user3"])# Single page
leaderboard = await client.leaderboards("money", page=1)
# Batch fetch multiple pages
pages = await client.leaderboards.batch("money", start_page=1, end_page=100)
# Category shortcuts
await client.leaderboards.money(page=1)
await client.leaderboards.kills(page=1)
await client.leaderboards.playtime(page=1)Available categories: money, shards, playtime, kills, deaths, mobskilled, brokenblocks, placedblocks, sell, shop
# List active auctions
auctions = await client.auction.list(page=1, search="diamond", sort="price_asc")
# Recent transactions
transactions = await client.auction.transactions(page=1)# Single lookup
player = await client.lookup("username")
# Batch lookup
players = await client.lookup.batch(["user1", "user2", "user3"])See the examples directory for more usage patterns:
stats.py- Basic stats lookupbatch_stats.py- Batch stats lookup for multiple usersbatch_leaderboard.py- Fetching multiple leaderboard pagesfinished_auctions.py- Polling for new auction transactionsleaderboard_estimation.py- Estimating total server wealth using adaptive sampling
MIT