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.

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

donutstats-1.2.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

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

Hashes for donutstats-1.2.2.tar.gz
Algorithm Hash digest
SHA256 ae04e2b550c44d18b96f9a179b3631a35806c413cb32b37461c0e8a5cedda088
MD5 f0e70537f58b3d9ba79298875a078fa1
BLAKE2b-256 6de9ee713ff544057518b6bfa37b968f11873f0589b50ada9094ef06a6c60f63

See more details on using hashes here.

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

Hashes for donutstats-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85ef9db01ee620e80c77e134ace021f76a57a28a0ff6750e57f7f77f54005d78
MD5 e9f0b969cea7bdcdee681dc3dead1a6c
BLAKE2b-256 8f3649048d248833d980d53a6ee1d97ba1980cc958d8c3b1ad421b1f0b7d1c13

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 files

1.1.2

2 files

1.1.1

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page