donutstats
Async Python wrapper for the DonutSMP API.
Install
Requires python 3.12 or newer
Basic Install
pip install donutstats
Discord Feature Usage
pip install donutstats[discord]
Usage
Simple stats usage
import asyncio
from donutstats import DonutStats, DonutSMPError
async def main():
donutstats = DonutStats("Your DonutSMP api key (generate ingame with /api)")
# Full stats dict
stats = await donutstats.get_stats(username="copa6076") # Pull the stats from donutsmp api
print(stats.get('money')) # 2920840615
# Single stat
shards = await donutstats.get_shards(username="copa6076") # Pull the shards from donutsmp api
print(shards) # 8410
# Lookup
lookup = await donutstats.lookup("copa6076")
print(lookup) # {'username': 'copa6076', 'rank': 'Unknown', 'location': 'Overworld'}
print(lookup.get('location')) # 'Overworld'
# Unfound Player
try:
shards = await donutstats.get_shards(username="idontexist123d7") # Pull the shards from donutsmp api
print(shards)
except DonutSMPError:
# This code runs when the player is not found
print("Could not find player")
await donutstats.close() # Close it when you close your bot
asyncio.run(main())
Functions
| Name | Args | Returns |
|---|---|---|
await get_stats |
username: str |
dict[str, int] |
await lookup |
username: str |
dict[str, str] |
await get_broken_blocks |
username: str |
int |
await get_deaths |
username: str |
int |
await get_kills |
username: str |
int |
await get_mobs_killed |
username: str |
int |
await get_balance |
username: str |
int |
await get_money_made_from_sell |
username: str |
int |
await get_money_spent_on_shop |
username: str |
int |
await get_placed_blocks |
username: str |
int |
await get_playtime |
username: str |
int |
await get_shards |
username: str |
int |
await get_stats_embed |
username: str, color: discord.Color | Default |
discord.Embed - requires donutstats[discord] |
await close |
None |
None - Closes the session |
Exceptions
DonutSMPError- Raised when DonutSMP cannot handle a query - Likely cannot find player/page/itemUnauthorizedRequest- Raised when DonutSMP returns a 401 unauthorized.RateLimited- Raised when DonutSMP returns a 429 ratelimitedUnexpectedError- Raised when there is an unexpected api response status.
License
Released under the MIT License. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
donutstats-1.2.2.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file donutstats-1.2.2.tar.gz.
File metadata
- Download URL: donutstats-1.2.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae04e2b550c44d18b96f9a179b3631a35806c413cb32b37461c0e8a5cedda088
|
|
| MD5 |
f0e70537f58b3d9ba79298875a078fa1
|
|
| BLAKE2b-256 |
6de9ee713ff544057518b6bfa37b968f11873f0589b50ada9094ef06a6c60f63
|
File details
Details for the file donutstats-1.2.2-py3-none-any.whl.
File metadata
- Download URL: donutstats-1.2.2-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85ef9db01ee620e80c77e134ace021f76a57a28a0ff6750e57f7f77f54005d78
|
|
| MD5 |
e9f0b969cea7bdcdee681dc3dead1a6c
|
|
| BLAKE2b-256 |
8f3649048d248833d980d53a6ee1d97ba1980cc958d8c3b1ad421b1f0b7d1c13
|