Skip to main content

donutstats

Async Python wrapper for the DonutSMP API.

PyPI PyPI Downloads Tests

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/item
  • UnauthorizedRequest - Raised when DonutSMP returns a 401 unauthorized.
  • RateLimited - Raised when DonutSMP returns a 429 ratelimited
  • UnexpectedError - Raised when there is an unexpected api response status.

License

Released under the MIT License. See LICENSE.

Metadata

Release files for donutstats 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for donutstats 1.2.2
File Size Uploaded
donutstats-1.2.2.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for donutstats 1.2.2
File Interpreter ABI Platform
donutstats-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / donutstats-1.2.2.tar.gz

Download URL donutstats-1.2.2.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ae04e2b550c44d18b96f9a179b3631a35806c413cb32b37461c0e8a5cedda088
BLAKE2b-256 checksum
How to use checksums
6de9ee713ff544057518b6bfa37b968f11873f0589b50ada9094ef06a6c60f63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / donutstats-1.2.2-py3-none-any.whl

Download URL donutstats-1.2.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85ef9db01ee620e80c77e134ace021f76a57a28a0ff6750e57f7f77f54005d78
BLAKE2b-256 checksum
How to use checksums
8f3649048d248833d980d53a6ee1d97ba1980cc958d8c3b1ad421b1f0b7d1c13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page