Clash Royale API — Python
An unofficial Python wrapper for the official Clash Royale API (https://developer.clashroyale.com).
It handles the HTTP calls, authentication, tag encoding, pagination and retries, and returns typed models for the API's responses.
This project is not affiliated with, endorsed, or sponsored by Supercell. You need your own token from the official developer portal.
Getting started
pip install clash-royale-api-py
Grab a free token at developer.clashroyale.com/#/account and you're ready.
Usage
from clash_royale_api_py import ClashRoyaleAPI
api = ClashRoyaleAPI("the-token-you-got-from-the-api")
# Get a clan — "2PP", "#2PP", " 2pp " are all accepted.
clan = api.clans.get("2PP")
print(clan.name, clan.clan_score)
# Rosters, wars and river races; paginated results are iterable.
for member in api.clans.members("2PP").iter_all():
print(member.name, member.trophies)
race = api.clans.current_river_race("2PP")
if race.clans:
print("Points:", [(c.name, c.points) for c in race.clans])
No token argument? The client reads the CLASH_ROYALE_API_TOKEN
(or CLASH_ROYALE_TOKEN_API) environment variable:
import os
os.environ["CLASH_ROYALE_API_TOKEN"] = "your-token"
api = ClashRoyaleAPI() # reads the env var for you
player = api.players.get("#LPP289")
print(player.name, player.trophies, player.arena.name)
Async support
Both clients share one implementation and behave the same way:
import asyncio
from clash_royale_api_py import AsyncClashRoyaleAPI
async def main():
async with AsyncClashRoyaleAPI("your-token") as api:
clan = await api.clans.get("2PP")
print(clan.name)
entries = await api.leaderboards.get(0)
async for entry in entries.iter_all():
print(entry.rank, entry.name)
asyncio.run(main())
Resources
| Client attribute | Available methods |
|---|---|
api.clans |
search, get, members, war_log, current_war (retired upstream — raises GoneError), river_race_log, current_river_race |
api.players |
get, upcoming_chests, battle_log |
api.cards |
list, all |
api.events |
list |
api.tournaments |
search, get |
api.global_tournaments |
list |
api.locations |
list, get, clan_rankings, clan_war_rankings, player_rankings, path_of_legend_players, path_of_legend_season_rankings, league_seasons, league_seasons_v2, league_season, league_season_rankings, global_tournament_rankings |
api.leaderboards |
list, get, league |
api.raw |
Escape hatch: api.raw.get("/players/%23ABC") for endpoints that aren't wrapped |
Methods that return a Page accept limit=, after= and before=; see the
Resources docs
for the full list.
Errors
Failures raise a specific exception type per HTTP status:
from clash_royale_api_py import AuthenticationError, InvalidTagError, NotFoundError
try:
clan = api.clans.get("2PP")
except InvalidTagError as e:
print(e) # bad tag characters, raised before any request
except AuthenticationError as e:
print(e) # invalid token, or the server IP isn't whitelisted
except NotFoundError as e:
print(e.status) # 404 (this also catches GoneError, a 410)
Throttled (429) and 5xx responses are retried with exponential backoff by
default. Tune it with max_retries=, retry_backoff= and max_retry_delay=,
or pass max_retries=0 to disable retries.
Using a proxy
The official API only accepts requests from IPs whitelisted on your token. If your server can't hold a stable IP, use the RoyaleAPI proxy:
api = ClashRoyaleAPI(
"your-token",
base_url="https://proxy.royaleapi.dev/v1",
)
The Configuration docs
cover timeouts, retries and bringing your own httpx client.
About the proxy server
The proxy server is a service provided by the RoyaleAPI team. It allows you to make requests to the official API without whitelisting every IP you use. If you want to host your own, there's a Nuxt web app for that at https://github.com/AndreVarandas/royale-proxy-api.
Development
uv sync # install everything
uv run pytest # tests (fully offline, via respx)
uv run ruff check src tests
uv run mypy src
uv run mkdocs serve # the docs site
Runnable scripts live in examples/.
License
MIT — see LICENSE.
This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell, and Supercell is not responsible for it. For more information see Supercell's Fan Content Policy.
Metadata
Release files for clash-royale-api-py 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clash_royale_api_py-0.1.1.tar.gz | 23.9 kB | With provenance | Details for clash_royale_api_py-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clash_royale_api_py-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for clash_royale_api_py-0.1.1-py3-none-any.whl |
Total release size: 57.8 kB
Release files / clash_royale_api_py-0.1.1.tar.gz
| Download URL | clash_royale_api_py-0.1.1.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
618f7fa8bd289142168433cb1857948b0c2dd830055eeb446e66b7ab8dcd4a0d
|
|
BLAKE2b-256 checksum How to use checksums |
520e723a360bcaad6ab7640a7f580f479e51a56981b7eb8a3b5ea2a3e7d65983
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logRelease files / clash_royale_api_py-0.1.1-py3-none-any.whl
| Download URL | clash_royale_api_py-0.1.1-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30e87b424ab225ee0136c58490e3d99aba22e933167ed86141f74be125ba36c1
|
|
BLAKE2b-256 checksum How to use checksums |
85e5deb0bb421daa39255f94433daae3ba9637ec8f8d6f188c88cf5fe5c6e139
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logSecurity for clash-royale-api-py 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for clash_royale_api_py-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.