Metadata-Version: 2.4
Name: donutstats
Version: 1.1.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: 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) ![Python](https://img.shields.io/pypi/pyversions/donutstats) ![License](https://img.shields.io/pypi/l/donutstats)

[![tests](https://github.com/optccopa/donutstats/actions/workflows/tests.yml/badge.svg)](https://github.com/optccopa/donutstats/actions/workflows/tests.yml)

## Install

### Basic Install
```bash
pip install donutstats
```

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

## Usage

### Simple api usage
```python
import asyncio
from donutstats import DonutStats

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

    await donutstats.close() # Close it when you close your bot

asyncio.run(main())
```

### Simple discord bot cog usage
```python
import discord
from discord.ext import commands

from donutstats import DonutStats

class Stats(commands.Cog):
    def __init__(self, bot: commands.Bot):
        # Initialize donutstats when your cog gets initialized
        self.donutstats = DonutStats("Your DonutSMP api key (generate ingame with /api")

    @discord.app_commands.command()
    async def stats(self, interaction: discord.Interaction, username: str):
        # Returns a full stats embed
        embed: discord.Embed = await self.donutstats.get_stats_embed(username, discord.Color.blue())

        await interaction.response.send_message(embed=embed)

async def setup(bot: commands.Bot):
    await bot.add_cog(Stats(bot))
```
## Exceptions

- `DonutSMPError` - Raised when DonutSMP cannot handle a query, Very likely could not find username
- `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

MIT License [LICENSE](LICENSE)
