MageCorp.ClashRoyaleApi.Client 1.4.8

dotnet add package MageCorp.ClashRoyaleApi.Client --version 1.4.8                
NuGet\Install-Package MageCorp.ClashRoyaleApi.Client -Version 1.4.8                
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="MageCorp.ClashRoyaleApi.Client" Version="1.4.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MageCorp.ClashRoyaleApi.Client --version 1.4.8                
#r "nuget: MageCorp.ClashRoyaleApi.Client, 1.4.8"                
#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.
// Install MageCorp.ClashRoyaleApi.Client as a Cake Addin
#addin nuget:?package=MageCorp.ClashRoyaleApi.Client&version=1.4.8

// Install MageCorp.ClashRoyaleApi.Client as a Cake Tool
#tool nuget:?package=MageCorp.ClashRoyaleApi.Client&version=1.4.8                

MageCorp.ClashRoyaleApi.Client

Client library (C# wrapper) written in .NET (7.0/8.0) that provides an easy way to interact with the official Clash Royale API directly or through proxy

Stable
Clash Royale API Client NuGet

Supported Platforms

  • .Net 7.0; .Net 8.0

Features

  • Dependency injection ready (can also be used standalone, see below)
  • Supports async calls.

Table of Contents

  1. Installation
  2. Usage
  3. License

<a name="installation"></a> Installation

Logo Stable
Clash Royale API Client <img src="https://raw.githubusercontent.com/rodrigopiccelli/MageCorp.ClashRoyaleApi.Client/master/icon.png" width="150" height="150" title="Github Logo"> NuGet

Following commands can be used to install MageCorp.ClashRoyaleApi.Client, run the following command in the Package Manager Console

NuGet\Install-Package MageCorp.ClashRoyaleApi.Client

Or use dotnet cli

dotnet add package MageCorp.ClashRoyaleApi.Client

<a name="usage"></a> Usage

<a name="standalone-initialization"></a> Standalone Initialization

If you do not want to use any DI framework, you have to instantiate ClashRoyaleApiClient as follows.

<a name="clashroyaleapistandalone"></a> ClashRoyaleApiClient Standalone Usage
ApiOptions apiOptions = new("<your token>");
var clashRoyaleApiClient = ClashRoyaleApiClient.Create(apiOptions);
var playersService = clashRoyaleApiClient.PlayersService;
var clansService = clashRoyaleApiClient.ClansService;

clashRoyaleApiClient contains all necessary clients.

<a name="di-initialization"></a> Microsoft.Extensions.DependencyInjection Initialization

First, you need to install Microsoft.Extensions.DependencyInjection NuGet package as follows

dotnet add package Microsoft.Extensions.DependencyInjection
<a name="clash-royale-api"></a> Clash Royale Api

Register necessary dependencies to ServiceCollection as follows

var serviceProvider = new ServiceCollection()
    .AddClashRoyaleApiClient("<yor token>")
    .BuildServiceProvider();

Or

var serviceProvider = new ServiceCollection()
    .AddClashRoyaleApiClient(new ApiOptions("<your token>"))
    .BuildServiceProvider();

Getting services:

var cardsService = serviceProvider.GetRequiredService<ICardsService>();
var challengesService = serviceProvider.GetRequiredService<IChallengesService>();
var clansService = serviceProvider.GetRequiredService<IClansService>();
var globalTournamentsService = serviceProvider.GetRequiredService<IGlobalTournamentsService>();
var locationsService = serviceProvider.GetRequiredService<ILocationsService>();
var playersService = serviceProvider.GetRequiredService<IPlayersService>();
var tournamentsService = serviceProvider.GetRequiredService<ITournamentsService>();
<a name="using-configuration"></a> Using Configuration

There is an extension that supports Microsoft.Extensions.Configuration to store the ApiOptions configuration as follows

{
  "ApiOptions": {
    "BearerToken": "<your token>",
    "ApiAddress": "https://api.clashroyale.com",
    "ApiVerstion": "v1",
    "UseProxy": false,
    "ProxyAddress": "https://proxy.royaleapi.dev"
  }
}
string basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
var configuration = new ConfigurationBuilder()
    .SetBasePath(basePath)
    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
    .AddEnvironmentVariables()
    .Build();
    
var serviceProvider = new ServiceCollection()
    .AddClashRoyaleApiClient(provider => {
        //you can use provider to get any required service needed to initialize your ApiOptions
        return configuration.GetApiOptionsSection("<sectionName>"); //if you don't specify the sectionName it will be "ApiOptions" by default
    })
    .BuildServiceProvider();

<a name="license"></a> License

Licensed under MIT, see LICENSE for the full text.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.8 111 7/12/2024
1.4.7 121 7/9/2024 1.4.7 is deprecated because it has critical bugs.
1.4.5 114 5/31/2024
1.4.4 142 3/2/2024
1.4.3 216 12/15/2023
1.3.1 183 7/7/2023 1.3.1 is deprecated because it is no longer maintained.