Metadata-Version: 2.5
Name: async-royale-client
Version: 1.0.1
Summary: Typed async Python client for the official Clash Royale REST API
Project-URL: Homepage, https://github.com/EchterAlsFake/ClashRoyaleAPI
Project-URL: Documentation, https://docs.echteralsfake.me/clashroyaleapi/
Project-URL: Issues, https://github.com/EchterAlsFake/ClashRoyaleAPI/issues
Author-email: Johannes Habel <EchterAlsFake@proton.me>
License-Expression: GPL-3.0-only
License-File: LICENSE
Classifier: Framework :: AsyncIO
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: curl-cffi<1,>=0.13
Requires-Dist: pydantic<3,>=2.11
Description-Content-Type: text/markdown

# ClashRoyaleAPI

Typed, async-only Python client for all **30 documented GET endpoints** of the official Clash Royale REST API. Requires Python 3.12+; uses `curl_cffi` and Pydantic v2.

```sh
pip install async-royale-client
```

```python
import asyncio
import os
from clashroyaleapi import Client

async def main():
    async with Client(os.environ["CLASH_ROYALE_API_TOKEN"]) as client:
        player = await client.get_player("#2VVYYRVYP")
        print(player.name, player.trophies)
        async for card in client.iter_get_cards(limit=100):
            print(card.name)

asyncio.run(main())
```

Create your own token at https://developer.clashroyale.com and allowlist the public IP making requests. Authentication failures may indicate an IP mismatch rather than an invalid token.

[Documentation](https://docs.echteralsfake.me/clashroyaleapi/) · [User guide](docs/guide.md) · [Endpoint reference](docs/endpoints.md) · [Models](docs/models.md)

## Behavior

- Every network operation is async. Use `async with Client(...)` or `await client.close()`.
- Individual resources return Pydantic models, paginated endpoints return `Page[T]`, and unpaginated arrays return lists. `iter_<method_name>` methods traverse cursor pages.
- Models expose snake_case fields and retain unknown fields. `model.to_dict()` exports JSON-compatible data with original API aliases.
- Up to three attempts for GET requests encountering transport failures, 429, or 5xx. Retry delays are bounded to 30 seconds. Caching is opt-in.
- Complete endpoint coverage refers to the supplied official documentation snapshot, not a guarantee of upstream availability. Nested model definitions collapsed in that snapshot cannot be exhaustively validated. Deprecated endpoints remain supported.

## Development

```sh
uv sync --locked --python 3.12
uv run pytest
uv run ruff check src scripts tests
uv run mypy
uv run python scripts/build_docs.py
uv build
uv run twine check dist/*
```

The endpoint manifest is `docs/api-reference.json`. Explicit endpoint methods and response models are generated by `scripts/generate_client.py`; review changes to the manifest and generator before regeneration. Raw browser exports are excluded from Git because they may contain credentials. See [release instructions](docs/releasing.md).

## Migration

The unfinished `api.api.RoyaleAPI` interface is replaced by `clashroyaleapi.Client`. Add `await` to network calls and use async context management. Replace `get_player_chest_cycle` with `get_player_upcoming_chests` and read `.items`; battle logs are lists from `get_player_battle_log`. Model fields replace the old cached properties and generator accessors: use `player.cards`, `player.clan`, and `player.league_statistics`.

## License and affiliation

GPL-3.0-only; see LICENSE. This project is unofficial and is not affiliated with, endorsed, sponsored, or approved by Supercell. Supercell is not responsible for its operation or content. Clash Royale trademarks and game content belong to their respective owners.
