ClashRoyaleApiLib 1.0.1
dotnet add package ClashRoyaleApiLib --version 1.0.1
NuGet\Install-Package ClashRoyaleApiLib -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ClashRoyaleApiLib" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ClashRoyaleApiLib" Version="1.0.1" />
<PackageReference Include="ClashRoyaleApiLib" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ClashRoyaleApiLib --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ClashRoyaleApiLib, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ClashRoyaleApiLib@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ClashRoyaleApiLib&version=1.0.1
#tool nuget:?package=ClashRoyaleApiLib&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ClashRoyaleApi
A lightweight, fully typed C# wrapper for the Clash Royale API v1.
Installation
dotnet add package ClashRoyaleApi
Quick Start
Get an API key from the Clash Royale Developer Portal.
using ClashRoyaleApi;
var client = new ClashRoyaleClient("your_api_key");
var player = await client.GetPlayerAsync("#2PP");
Console.WriteLine($"{player.Name} — {player.Trophies} trophies");
var clan = await client.GetClanAsync("#2C22YLUR");
Console.WriteLine($"{clan.Name} — {clan.Members}/{clan.MaxMembers} members");
Player and clan tags may be passed with or without the leading # — both are accepted.
Dependency Injection / HttpClient Factory
// Program.cs
builder.Services.AddHttpClient<ClashRoyaleClient>(client =>
{
client.BaseAddress = new Uri("https://api.clashroyale.com/v1/");
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "your_api_key");
client.Timeout = TimeSpan.FromSeconds(30);
});
API Coverage
Players
| Method | Description |
|---|---|
GetPlayerAsync(playerTag) |
Full player profile |
GetPlayerBattleLogAsync(playerTag) |
Recent battle log (up to 25 battles) |
GetPlayerUpcomingChestsAsync(playerTag) |
Upcoming chest sequence |
Clans
| Method | Description |
|---|---|
SearchClansAsync(name, locationId, ...) |
Search clans by filter criteria |
GetClanAsync(clanTag) |
Full clan info including member list |
GetClanMembersAsync(clanTag) |
Paginated clan member list |
GetClanWarLogAsync(clanTag) |
Legacy war log |
GetCurrentRiverRaceAsync(clanTag) |
Current River Race state |
GetRiverRaceLogAsync(clanTag) |
River Race history |
Cards
| Method | Description |
|---|---|
GetCardsAsync() |
All cards and support cards |
Tournaments
| Method | Description |
|---|---|
SearchTournamentsAsync(name) |
Search open tournaments |
GetTournamentAsync(tournamentTag) |
Tournament details and rankings |
GetGlobalTournamentsAsync() |
Current global ladder tournaments |
GetGlobalTournamentRankingsAsync(tournamentTag) |
Rankings for a global tournament |
Events
| Method | Description |
|---|---|
GetEventsAsync() |
Current in-game trail events |
Leaderboards
| Method | Description |
|---|---|
GetLeaderboardsAsync() |
All available leaderboards |
GetLeaderboardAsync(leaderboardId) |
Specific leaderboard by ID |
Locations
| Method | Description |
|---|---|
GetLocationsAsync() |
All locations/countries |
GetLocationAsync(locationId) |
Specific location |
GetClanRankingsAsync(locationId) |
Clan trophy rankings by location |
GetPlayerRankingsAsync(locationId) |
Player trophy rankings by location |
GetClanWarRankingsAsync(locationId) |
Clan war rankings by location |
GetLocationPathOfLegendRankingsAsync(locationId) |
Path of Legend rankings by location |
Seasons
| Method | Description |
|---|---|
GetSeasonsAsync() |
All league seasons |
GetSeasonsV2Async() |
All league seasons (v2) |
GetSeasonAsync(seasonId) |
Specific season (e.g. "2025-01") |
GetSeasonPlayerRankingsAsync(seasonId) |
Trophy rankings for a completed season |
GetGlobalPathOfLegendRankingsAsync(seasonId) |
Global Path of Legend rankings for a season |
Pagination
All list endpoints return PagedResponseDto<T> with cursor-based pagination:
var page1 = await client.GetClanMembersAsync("#2C22YLUR", limit: 10);
if (page1.Paging?.Cursors?.After is string cursor)
{
var page2 = await client.GetClanMembersAsync("#2C22YLUR", limit: 10, after: cursor);
}
Error Handling
All API errors throw ClashRoyaleApiException:
try
{
var player = await client.GetPlayerAsync("#INVALID");
}
catch (ClashRoyaleApiException ex)
{
Console.WriteLine(ex.StatusCode); // e.g. 404
Console.WriteLine(ex.Reason); // e.g. "notFound"
Console.WriteLine(ex.Message); // human-readable description
}
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.