Metadata-Version: 2.4
Name: donutstats
Version: 1.2.2
Summary: Async client for the DonutSMP API
Project-URL: Homepage, https://github.com/optccopa/DonutStats
Project-URL: Issues, https://github.com/optccopa/DonutStats/issues
Author: optccopa
License: MIT License
        
        Copyright (c) 2026 ryder4est
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: async,donutsmp,minecraft,stats
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: aiohttp>=3.9
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pre-commit>=3.7; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: discord
Requires-Dist: discord-py>=2.0; extra == 'discord'
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# donutstats

Async Python wrapper for the [DonutSMP](https://donutsmp.net) API.

![PyPI](https://img.shields.io/pypi/v/donutstats?cacheSeconds=3600)
[![PyPI Downloads](https://img.shields.io/pypi/dw/donutstats?cacheSeconds=3600)](https://pypi.org/project/donutstats/)
[![Tests](https://github.com/optccopa/donutstats/actions/workflows/tests.yml/badge.svg)](https://github.com/optccopa/donutstats/actions/workflows/tests.yml)

## Install

Requires python 3.12 or newer
### Basic Install
```bash
pip install donutstats
```

### Discord Feature Usage
```bash
pip install donutstats[discord]
```

## Usage

### Simple stats usage
```python
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](LICENSE).
