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
async with Client(...) or await client.close().Page[T], and unpaginated arrays return lists. iter_<method_name> methods traverse cursor pages.model.to_dict() exports JSON-compatible data with original API aliases.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.
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.
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.
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.
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.
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.
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")
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 /clans/{clanTag}/warlogget_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
GET /clanssearch_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 /clans/{clanTag}/riverracelogget_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 /clans/{clanTag}/currentwarget_current_war(self, clan_tag: str) -> clashroyaleapi.models.CurrentClanWarRetrieve information about clan's current clan war
GET /clans/{clanTag}get_clan(self, clan_tag: str) -> clashroyaleapi.models.ClanGet 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 /clans/{clanTag}/membersget_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 /clans/{clanTag}/currentriverraceget_current_river_race(self, clan_tag: str) -> clashroyaleapi.models.CurrentRiverRaceRetrieve information about clan's current river race
GET /players/{playerTag}get_player(self, player_tag: str) -> clashroyaleapi.models.PlayerGet 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 /players/{playerTag}/upcomingchestsget_player_upcoming_chests(self, player_tag: str) -> clashroyaleapi.models.UpcomingChestsGet list of reward chests that the player will receive next in the game.
GET /players/{playerTag}/battlelogget_player_battle_log(self, player_tag: str) -> list[clashroyaleapi.models.Battle]Get list of recent battles for a player
GET /cardsget_cards(self, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Item]Get list of available cards
GET /tournamentssearch_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 /tournaments/{tournamentTag}get_tournament(self, tournament_tag: str) -> clashroyaleapi.models.TournamentGet information about a single tournament by a tournament tag.
GET /locations/{locationId}/rankings/clansget_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 /locations/{locationId}/rankings/playersget_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 /locations/{locationId}/rankings/clanwarsget_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 /locations/global/pathoflegend/{seasonId}/rankings/playersget_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 /locations/global/seasons/{seasonId}get_season(self, season_id: str) -> clashroyaleapi.models.LeagueSeasonGet top player league season.
GET /locations/global/seasons/{seasonId}/rankings/playersget_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 /locations/global/seasonsget_seasons(self) -> list[clashroyaleapi.models.LeagueSeason]Lists top player league seasons.
GET /locationsget_locations(self, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Location]List locations
GET /locations/global/seasonsV2get_seasons_v2(self) -> list[clashroyaleapi.models.LeagueSeason]Lists league seasons with unique season IDs and season end times.
GET /locations/{locationId}get_location(self, location_id: str) -> clashroyaleapi.models.LocationGet information about specific location
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 /locations/{locationId}/pathoflegend/playersget_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 /eventsget_events(self) -> list[clashroyaleapi.models.TrailEvent]Get current events. Returns a list of ongoing events with its Title and Description localized.
GET /leaderboard/{leaderboardId}get_leaderboard(self, leaderboard_id: int, *, limit: int | None = None, after: str | None = None, before: str | None = None) -> clashroyaleapi.models.Page[Leaderboard]Get players on a specific leaderboard
GET /leaderboardsget_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/{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 /globaltournamentsget_global_tournaments(self) -> list[clashroyaleapi.models.LadderTournament]Get list of global tournaments
id: int | None
name: str | Nonetype: 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')index: int | None
name: str | Nonebadge_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 | Nonetag: 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 | Nonetag: str | None
name: str | None
rank: int | None
previous_rank: int | None
clan_score: int | None
members: int | None
location: ForwardRef('Location | None')tag: str | None
name: str | None
badge_id: int | None
clan_score: int | Nonecreated_date: datetime.datetime | None
standings: ForwardRef('list[ClanWarStanding] | None')
participants: ForwardRef('list[ClanWarParticipant] | None')tag: str | None
name: str | None
wins: int | None
battles_played: int | Nonerank: int | None
trophy_change: int | None
clan: clashroyaleapi.models.ClanWarClan | Nonestate: 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 | Nonestate: 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')before: str | None
after: str | Noneid: int | None
name: str | Noneid: 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 | Noneitems: list[clashroyaleapi.models.Item] | None
support_items: list[clashroyaleapi.models.Item] | Noneid: int | None
title: str | None
game_mode: clashroyaleapi.models.GameMode | None
start_time: datetime.datetime | None
end_time: datetime.datetime | Nonetag: str | None
name: str | None
rank: int | None
score: int | None
clan: ForwardRef('PlayerRankingClan | None')id: int | None
name: typing.Any | None
leagues: typing.Any | Nonetag: str | None
name: str | None
rank: int | None
score: int | Noneid: str | Noneid: str | None
trophies: int | None
best_trophies: int | None
rank: int | Nonelocalized_name: str | None
id: int | None
name: str | None
is_country: bool | None
country_code: str | Noneitems: list[~T]
paging: <class 'clashroyaleapi.models.Paging'>cursors: <class 'clashroyaleapi.models.Cursors'>league_number: int | None
trophies: int | None
rank: int | Noneperiod_index: int | None
items: ForwardRef('list[PeriodLogEntry] | None')clan: ForwardRef('PeriodLogEntryClan | None')
points_earned: int | Nonetag: str | None
name: str | Noneclan: 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 | Nonename: str | None
level: int | None
max_level: int | None
progress: int | None
target: int | None
icon_urls: typing.Any | Nonename: str | None
stars: int | None
value: int | None
target: int | None
info: str | None
completion_info: str | Nonetag: 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 | Nonetag: str | None
name: str | None
badge_id: int | Noneid: 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 | Nonecurrent_season: clashroyaleapi.models.LeagueSeasonResult | None
previous_season: clashroyaleapi.models.LeagueSeasonResult | None
best_season: clashroyaleapi.models.LeagueSeasonResult | Nonetag: str | None
name: str | None
rank: int | None
trophies: int | None
clan: ForwardRef('PlayerRankingClan | None')tag: str | None
name: str | None
rank: int | None
previous_rank: int | None
trophies: int | None
clan: ForwardRef('PlayerRankingClan | None')tag: str | None
name: str | None
badge_id: int | Nonetag: 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')season_id: int | None
section_index: int | None
created_date: datetime.datetime | None
standings: ForwardRef('list[RiverRaceStanding] | None')tag: str | None
name: str | None
fame: int | None
repair_points: int | None
decks_used: int | None
decks_used_today: int | Nonerank: int | None
trophy_change: int | None
clan: clashroyaleapi.models.RiverRaceClan | Nonegame_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 | Nonetag: str | None
name: str | None
status: str | None
capacity: int | None
max_capacity: int | Nonetag: str | None
name: str | None
rank: int | None
score: int | Noneid: int | None
title: typing.Any | None
description: typing.Any | Noneitems: list[clashroyaleapi.models.Chest] | None