Skip to main content

Clash Royale API — Python

PyPI Python CI Coverage Docs License: MIT

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clash-royale-api-py 0.1.0
File Size Uploaded Provenance Actions
clash_royale_api_py-0.1.0.tar.gz 23.9 kB With provenance Details for clash_royale_api_py-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clash-royale-api-py 0.1.0
File Interpreter ABI Platform Actions
clash_royale_api_py-0.1.0-py3-none-any.whl Python 3 none any Details for clash_royale_api_py-0.1.0-py3-none-any.whl

Total release size: 58.0 kB

Release files / clash_royale_api_py-0.1.0.tar.gz

Download URL clash_royale_api_py-0.1.0.tar.gz
Size 23.9 kB
Tags Source
SHA-256 checksum
How to use checksums
238f4a2bed3c76967eb92886dba7ea23b8c81efed903e17755d4447a40d45a50
BLAKE2b-256 checksum
How to use checksums
537faca5fe13480ed7e0951c3a1baab81eedb764cbec54ad0a17910e22c2b753
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 log

Release files / clash_royale_api_py-0.1.0-py3-none-any.whl

Download URL clash_royale_api_py-0.1.0-py3-none-any.whl
Size 34.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa1441b744d179d5e2b4634379e13d09ca324a0f5214bcc57d19123826e88042
BLAKE2b-256 checksum
How to use checksums
cd0983a16eed04fc94c8a37e05f9628dd136b04cfe213b2549de811db9dafaeb
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 log

Security for clash-royale-api-py 0.1.0

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.

Select from 2 files

Attestation for clash_royale_api_py-0.1.0.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page