Getting startedUser guideget_clan_war_logsearch_clansget_clan_river_race_logget_current_warget_clanget_clan_membersget_current_river_raceget_playerget_player_upcoming_chestsget_player_battle_logget_cardssearch_tournamentsget_tournamentget_clan_rankingget_player_rankingget_clan_wars_rankingget_top_player_path_of_legend_season_rankingsget_seasonget_top_player_league_season_rankingsget_seasonsget_locationsget_seasons_v2get_locationget_global_tournament_rankingget_player_path_of_legend_rankingget_eventsget_leaderboardget_leaderboardsget_leaderboard_leagueget_global_tournamentsAPIModelCursorsPagingPageArenaBattleChestClanClanMemberClanRankingClanWarClanClanWarLogEntryClanWarParticipantClanWarStandingCurrentClanWarCurrentRiverRaceGameModeItemItemsLadderTournamentLadderTournamentRankingLeaderboardLeaderboardEntryLeagueSeasonLeagueSeasonResultLeagueSeasonV2LocationPathOfLegendSeasonResultPeriodLogPeriodLogEntryPeriodLogEntryClanPlayerPlayerAchievementBadgePlayerAchievementProgressPlayerBattleDataPlayerClanPlayerItemLevelPlayerLeagueStatisticsPlayerPathOfLegendRankingPlayerRankingPlayerRankingClanRiverRaceClanRiverRaceLogEntryRiverRaceParticipantRiverRaceStandingTournamentTournamentHeaderTournamentMemberTrailEventUpcomingChests

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.

pip install async-royale-client
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 · User guide · Endpoint reference · Models

Behavior

Live verification: all 30 routes were exercised; 26 operations succeeded, two are explicitly disabled, and two lack working live resources. See live audit results and rerun instructions.

Development

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.

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.

User guide

Authentication and lifecycle

Generate a token in the official Clash Royale developer dashboard and allowlist your outgoing public IP. Pass the token explicitly; examples read CLASH_ROYALE_API_TOKEN. Never embed credentials in code. Use the client within one asyncio event loop and close it before that loop ends.

Configuration

Client(api_token, *, timeout=20, proxy=None, verify=True, max_clients=10, base_url="https://api.clashroyale.com/v1", max_attempts=3, cache_ttl=0, cache_size=256)

Timeout is in seconds; max_clients bounds pooled curl handles. proxy accepts a proxy URL. TLS certificate verification defaults to enabled. A custom base URL allows a caller-selected API proxy or local testing; your bearer token is sent to that URL. Redirects are disabled. There is no browser impersonation requirement.

max_attempts is 1–3. Retried failures are network errors, HTTP 429, and HTTP 5xx. Backoff starts at 0.5 seconds. Retry-After supports seconds and HTTP dates, capped at 30 seconds. Cancellation propagates immediately.

cache_ttl=0 disables caching. Positive TTL enables a bounded per-client LRU cache. Keys include path and query parameters. Only successful JSON results are cached; empty results are valid cache entries. Cached data is copied before conversion to prevent mutation of later responses.

Responses and pagination

Models use snake_case attributes; missing optional fields are None. Unknown fields survive to_dict(). Known nested resources are typed; unresolved or undocumented structures remain JSON values. This export included nine expanded object schemas; conservative convenience fields supplement collapsed nested schemas. This is endpoint-complete coverage, not a claim of an exhaustive upstream schema.

Paginated methods return Page[T]. Access .items, .paging.cursors.after and .paging.cursors.before. Additional envelope fields, such as card catalog supportItems, remain accessible as retained extras and through to_dict().

Call iter_get_clan_members(clan_tag, limit=100) or the corresponding iter_ method to traverse pages. limit is the upstream page size, not a total item limit. Passing before traverses backwards; otherwise iterators follow after. Iteration stops at an empty page or missing cursor. A repeated cursor raises InvalidResponse to prevent an endless loop. Do not pass both cursors.

Tags accept ABC, #ABC, or %23ABC and are encoded once. Query parameters use Python snake_case and are serialized with official camelCase names. Clan search requires at least one filter; name searches require at least three characters. Search ordering is unspecified upstream.

Errors

All library request exceptions inherit APIError, with .status, .reason, and .detail. Catch AuthenticationError for 401/403, InvalidParameter for 400, NotFound for 404, RateLimitExceeded for 429, ServerError for 5xx, NetworkError for transfer failures, and InvalidResponse for malformed JSON or response shapes. Other non-200 responses raise APIError. Invalid local arguments raise ValueError. Closed clients raise RuntimeError.

from clashroyaleapi import Client, AuthenticationError, RateLimitExceeded

async def lookup(token, tag):
    async with Client(token) as client:
        try:
            return await client.get_player(tag)
        except AuthenticationError:
            print("Check the token and your public IP allowlist")
        except RateLimitExceeded:
            print("The API remains rate limited after retries")

Upstream limitations

The reference is the user-provided rendered official Swagger UI export, identified by SHA-256 in api-reference.json. Its leaderboard models reference a missing List definition. Those fields retain raw data. Location Trophy Road player rankings are deprecated and documented to always return an empty list; use Path of Legend endpoints instead. Legacy clan-war endpoints may be unavailable upstream. Related models such as VerifyTokenRequest or RegisterMatchRequest do not establish public routes; no speculative endpoints are implemented. There is no standalone challenges operation in this snapshot.

get_clan_war_log

GET /clans/{clanTag}/warlog
get_clan_war_log(self, clan_tag: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[ClanWarLogEntry]

Retrieve clan's clan war log

search_clans

GET /clans
search_clans(self, *, name: str | None = None, location_id: int | None = None, min_members: int | None = None, max_members: int | None = None, min_score: int | None = None, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Clan]

Search all clans by name and/or filtering the results using various criteria. At least one filtering criteria must be defined and if name is used as part of search, it is required to be at least three characters long It is not possible to specify ordering for results so clients should not rely on any specific ordering as that may change in the future releases of the API.

get_clan_river_race_log

GET /clans/{clanTag}/riverracelog
get_clan_river_race_log(self, clan_tag: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[RiverRaceLogEntry]

Retrieve clan's river race log

get_current_war

GET /clans/{clanTag}/currentwar
get_current_war(self, clan_tag: str) -> clashroyaleapi.models.CurrentClanWar

Retrieve information about clan's current clan war

get_clan

GET /clans/{clanTag}
get_clan(self, clan_tag: str) -> clashroyaleapi.models.Clan

Get information about a single clan by clan tag. Clan tags can be found using clan search operation. Note that clan tags start with hash character '#' and that needs to be URL-encoded properly to work in URL, so for example clan tag '#2ABC' would become '%232ABC' in the URL.

get_clan_members

GET /clans/{clanTag}/members
get_clan_members(self, clan_tag: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[ClanMember]

List clan members.

get_current_river_race

GET /clans/{clanTag}/currentriverrace
get_current_river_race(self, clan_tag: str) -> clashroyaleapi.models.CurrentRiverRace

Retrieve information about clan's current river race

get_player

GET /players/{playerTag}
get_player(self, player_tag: str) -> clashroyaleapi.models.Player

Get information about a single player by player tag. Player tags can be found either in game or by from clan member lists. Note that player tags start with hash character '#' and that needs to be URL-encoded properly to work in URL, so for example player tag '#2ABC' would become '%232ABC' in the URL.

get_player_upcoming_chests

GET /players/{playerTag}/upcomingchests
get_player_upcoming_chests(self, player_tag: str) -> clashroyaleapi.models.UpcomingChests

Get list of reward chests that the player will receive next in the game.

get_player_battle_log

GET /players/{playerTag}/battlelog
get_player_battle_log(self, player_tag: str) -> list[clashroyaleapi.models.Battle]

Get list of recent battles for a player

get_cards

GET /cards
get_cards(self, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Item]

Get list of available cards

search_tournaments

GET /tournaments
search_tournaments(self, *, name: str | None = None, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[TournamentHeader]

Search all tournaments by name. It is not possible to specify ordering for results so clients should not rely on any specific ordering as that may change in the future releases of the API.

get_tournament

GET /tournaments/{tournamentTag}
get_tournament(self, tournament_tag: str) -> clashroyaleapi.models.Tournament

Get information about a single tournament by a tournament tag.

get_clan_ranking

GET /locations/{locationId}/rankings/clans
get_clan_ranking(self, location_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[ClanRanking]

Get clan rankings for a specific location

get_player_ranking

GET /locations/{locationId}/rankings/players
get_player_ranking(self, location_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[PlayerRanking]

Deprecated: this endpoint always returns an empty list and will be removed in a future version. Trophy road player rankings no longer exist; use the Path of Legend ranking endpoints instead.

get_clan_wars_ranking

GET /locations/{locationId}/rankings/clanwars
get_clan_wars_ranking(self, location_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[ClanRanking]

Get clan war rankings for a specific location

get_top_player_path_of_legend_season_rankings

GET /locations/global/pathoflegend/{seasonId}/rankings/players
get_top_player_path_of_legend_season_rankings(self, season_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[PlayerPathOfLegendRanking]

Get top Path of Legend players for given season.

get_season

GET /locations/global/seasons/{seasonId}
get_season(self, season_id: str) -> clashroyaleapi.models.LeagueSeason

Get top player league season.

get_top_player_league_season_rankings

GET /locations/global/seasons/{seasonId}/rankings/players
get_top_player_league_season_rankings(self, season_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[PlayerRanking]

Get top player rankings for a season.

get_seasons

GET /locations/global/seasons
get_seasons(self) -> list[clashroyaleapi.models.LeagueSeason]

Lists top player league seasons.

get_locations

GET /locations
get_locations(self, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Location]

List locations

get_seasons_v2

GET /locations/global/seasonsV2
get_seasons_v2(self) -> list[clashroyaleapi.models.LeagueSeasonV2]

Lists league seasons with unique season IDs and season end times.

get_location

GET /locations/{locationId}
get_location(self, location_id: str) -> clashroyaleapi.models.Location

Get information about specific location

get_global_tournament_ranking

GET /locations/global/rankings/tournaments/{tournamentTag}
get_global_tournament_ranking(self, tournament_tag: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[LadderTournamentRanking]

Get global tournament rankings

get_player_path_of_legend_ranking

GET /locations/{locationId}/pathoflegend/players
get_player_path_of_legend_ranking(self, location_id: str, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[PlayerPathOfLegendRanking]

Get player rankings in Path of Legend for a specific location

get_events

GET /events
get_events(self) -> list[clashroyaleapi.models.TrailEvent]

Get current events. Returns a list of ongoing events with its Title and Description localized.

get_leaderboard

GET /leaderboard/{leaderboardId}
get_leaderboard(self, leaderboard_id: int, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[LeaderboardEntry]

Get players on a specific leaderboard

get_leaderboards

GET /leaderboards
get_leaderboards(self) -> list[clashroyaleapi.models.Leaderboard]

List leaderboards for different trophy roads. A leaderboard with a board per competitive League lists its Leagues in leagues.

get_leaderboard_league

GET /leaderboard/{leaderboardId}/leagues/{leagueId}
get_leaderboard_league(self, leaderboard_id: int, league_id: int, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[LeaderboardEntry]

Get players on the board of one competitive League of a leaderboard

get_global_tournaments

GET /globaltournaments
get_global_tournaments(self) -> list[clashroyaleapi.models.LadderTournament]

Get list of global tournaments

APIModel

Cursors

before: str | None
after: str | None

Paging

cursors: <class 'clashroyaleapi.models.Cursors'>

Page

items: list[~T]
paging: <class 'clashroyaleapi.models.Paging'>

Arena

id: int | None
name: str | None

Battle

type: str | None
battle_time: datetime.datetime | None
is_ladder_tournament: bool | None
is_hosted_match: bool | None
deck_selection: str | None
league_number: int | None
game_mode: ForwardRef('GameMode | None')
arena: clashroyaleapi.models.Arena | None
team: ForwardRef('list[PlayerBattleData] | None')
opponent: ForwardRef('list[PlayerBattleData] | None')

Chest

index: int | None
name: str | None

Clan

badge_id: int | None
member_list: ForwardRef('list[ClanMember] | None')
clan_chest_status: str | None
clan_chest_level: int | None
clan_chest_max_level: int | None
clan_score: int | None
clan_war_trophies: int | None
required_trophies: int | None
donations_per_week: int | None
members: int | None
name: str | None
location: ForwardRef('Location | None')
type: str | None
tag: str | None
description: str | None
clan_chest_points: int | None
badge_urls: typing.Any | None

ClanMember

tag: str | None
name: str | None
role: str | None
last_seen: datetime.datetime | None
exp_level: int | None
trophies: int | None
clan_rank: int | None
previous_clan_rank: int | None
donations: int | None
donations_received: int | None
arena: clashroyaleapi.models.Arena | None

ClanRanking

tag: str | None
name: str | None
rank: int | None
previous_rank: int | None
clan_score: int | None
members: int | None
location: ForwardRef('Location | None')

ClanWarClan

tag: str | None
name: str | None
badge_id: int | None
clan_score: int | None

ClanWarLogEntry

created_date: datetime.datetime | None
standings: ForwardRef('list[ClanWarStanding] | None')
participants: ForwardRef('list[ClanWarParticipant] | None')

ClanWarParticipant

tag: str | None
name: str | None
wins: int | None
battles_played: int | None

ClanWarStanding

rank: int | None
trophy_change: int | None
clan: clashroyaleapi.models.ClanWarClan | None

CurrentClanWar

state: str | None
clan: clashroyaleapi.models.ClanWarClan | None
participants: list[clashroyaleapi.models.ClanWarParticipant] | None
clans: list[clashroyaleapi.models.ClanWarClan] | None
collection_end_time: datetime.datetime | None
war_end_time: datetime.datetime | None

CurrentRiverRace

state: str | None
clan: ForwardRef('RiverRaceClan | None')
clans: ForwardRef('list[RiverRaceClan] | None')
collection_end_time: datetime.datetime | None
war_end_time: datetime.datetime | None
section_index: int | None
period_index: int | None
period_type: str | None
period_logs: ForwardRef('list[PeriodLog] | None')

GameMode

id: int | None
name: str | None

Item

id: int | None
name: str | None
max_level: int | None
max_evolution_level: int | None
rarity: str | None
elixir_cost: int | None
icon_urls: typing.Any | None

Items

items: list[clashroyaleapi.models.Item] | None
support_items: list[clashroyaleapi.models.Item] | None

LadderTournament

id: int | None
title: str | None
game_mode: clashroyaleapi.models.GameMode | None
start_time: datetime.datetime | None
end_time: datetime.datetime | None

LadderTournamentRanking

tag: str | None
name: str | None
rank: int | None
score: int | None
clan: ForwardRef('PlayerRankingClan | None')

Leaderboard

id: int | None
name: typing.Any | None
leagues: typing.Any | None

LeaderboardEntry

tag: str | None
name: str | None
rank: int | None
score: int | None
clan: ForwardRef('PlayerClan | None')

LeagueSeason

id: str | None

LeagueSeasonResult

id: str | None
trophies: int | None
best_trophies: int | None
rank: int | None

LeagueSeasonV2

code: str | None
unique_id: int | None
end_time: datetime.datetime | None

Location

localized_name: str | None
id: int | None
name: str | None
is_country: bool | None
country_code: str | None

PathOfLegendSeasonResult

league_number: int | None
trophies: int | None
rank: int | None

PeriodLog

period_index: int | None
items: ForwardRef('list[PeriodLogEntry] | None')

PeriodLogEntry

clan: ForwardRef('PeriodLogEntryClan | None')
points_earned: int | None

PeriodLogEntryClan

tag: str | None
name: str | None

Player

clan: ForwardRef('PlayerClan | None')
legacy_trophy_road_high_score: int | None
current_deck: ForwardRef('list[PlayerItemLevel] | None')
current_deck_support_cards: ForwardRef('list[PlayerItemLevel] | None')
arena: clashroyaleapi.models.Arena | None
role: str | None
wins: int | None
losses: int | None
total_donations: int | None
league_statistics: ForwardRef('PlayerLeagueStatistics | None')
cards: ForwardRef('list[PlayerItemLevel] | None')
support_cards: ForwardRef('list[PlayerItemLevel] | None')
current_favourite_card: clashroyaleapi.models.Item | None
badges: ForwardRef('list[PlayerAchievementBadge] | None')
tag: str | None
name: str | None
collection_level: int | None
king_tower_level: int | None
exp_level: int | None
trophies: int | None
best_trophies: int | None
donations: int | None
donations_received: int | None
achievements: ForwardRef('list[PlayerAchievementProgress] | None')
battle_count: int | None
three_crown_wins: int | None
challenge_cards_won: int | None
challenge_max_wins: int | None
tournament_cards_won: int | None
tournament_battle_count: int | None
current_win_lose_streak: int | None
war_day_wins: int | None
clan_cards_collected: int | None
star_points: int | None
exp_points: int | None
total_exp_points: int | None
current_path_of_legend_season_result: clashroyaleapi.models.PathOfLegendSeasonResult | None
last_path_of_legend_season_result: clashroyaleapi.models.PathOfLegendSeasonResult | None
best_path_of_legend_season_result: clashroyaleapi.models.PathOfLegendSeasonResult | None
progress: typing.Any | None

PlayerAchievementBadge

name: str | None
level: int | None
max_level: int | None
progress: int | None
target: int | None
icon_urls: typing.Any | None

PlayerAchievementProgress

name: str | None
stars: int | None
value: int | None
target: int | None
info: str | None
completion_info: str | None

PlayerBattleData

tag: str | None
name: str | None
crowns: int | None
king_tower_hit_points: int | None
princess_towers_hit_points: typing.Any | None
clan: ForwardRef('PlayerClan | None')
cards: ForwardRef('list[PlayerItemLevel] | None')
trophy_change: int | None
elixir_leaked: float | None

PlayerClan

tag: str | None
name: str | None
badge_id: int | None

PlayerItemLevel

id: int | None
name: str | None
level: int | None
max_level: int | None
count: int | None
star_level: int | None
evolution_level: int | None
rarity: str | None
elixir_cost: int | None
icon_urls: typing.Any | None

PlayerLeagueStatistics

current_season: clashroyaleapi.models.LeagueSeasonResult | None
previous_season: clashroyaleapi.models.LeagueSeasonResult | None
best_season: clashroyaleapi.models.LeagueSeasonResult | None

PlayerPathOfLegendRanking

tag: str | None
name: str | None
rank: int | None
trophies: int | None
clan: ForwardRef('PlayerRankingClan | None')
elo_rating: int | None

PlayerRanking

tag: str | None
name: str | None
rank: int | None
previous_rank: int | None
trophies: int | None
clan: ForwardRef('PlayerRankingClan | None')

PlayerRankingClan

tag: str | None
name: str | None
badge_id: int | None

RiverRaceClan

tag: str | None
name: str | None
badge_id: int | None
fame: int | None
repair_points: int | None
clan_score: int | None
participants: ForwardRef('list[RiverRaceParticipant] | None')

RiverRaceLogEntry

season_id: int | None
section_index: int | None
created_date: datetime.datetime | None
standings: ForwardRef('list[RiverRaceStanding] | None')

RiverRaceParticipant

tag: str | None
name: str | None
fame: int | None
repair_points: int | None
decks_used: int | None
decks_used_today: int | None

RiverRaceStanding

rank: int | None
trophy_change: int | None
clan: clashroyaleapi.models.RiverRaceClan | None

Tournament

game_mode: clashroyaleapi.models.GameMode | None
status: str | None
preparation_duration: int | None
members_list: ForwardRef('list[TournamentMember] | None')
created_time: datetime.datetime | None
started_time: datetime.datetime | None
ended_time: datetime.datetime | None
first_place_card_prize: int | None
type: str | None
duration: int | None
tag: str | None
creator_tag: str | None
name: str | None
description: str | None
capacity: int | None
max_capacity: int | None
level_cap: int | None

TournamentHeader

tag: str | None
name: str | None
status: str | None
capacity: int | None
max_capacity: int | None

TournamentMember

tag: str | None
name: str | None
rank: int | None
score: int | None

TrailEvent

id: int | None
title: typing.Any | None
description: typing.Any | None
event_tag: str | None

UpcomingChests

items: list[clashroyaleapi.models.Chest] | None