MageCorp.ClashRoyaleApi.Client
1.3.1
See the version list below for details.
dotnet add package MageCorp.ClashRoyaleApi.Client --version 1.3.1
NuGet\Install-Package MageCorp.ClashRoyaleApi.Client -Version 1.3.1
<PackageReference Include="MageCorp.ClashRoyaleApi.Client" Version="1.3.1" />
paket add MageCorp.ClashRoyaleApi.Client --version 1.3.1
#r "nuget: MageCorp.ClashRoyaleApi.Client, 1.3.1"
// Install MageCorp.ClashRoyaleApi.Client as a Cake Addin #addin nuget:?package=MageCorp.ClashRoyaleApi.Client&version=1.3.1 // Install MageCorp.ClashRoyaleApi.Client as a Cake Tool #tool nuget:?package=MageCorp.ClashRoyaleApi.Client&version=1.3.1
MageCorp.ClashRoyaleApi.Client
Client library (C# wrapper) written in .NET 7.0 that provides an easy way to interact with the official Clash Royale API directly or through proxy
Stable | |
---|---|
Clash Royale API Client |
Supported Platforms
- .Net 7.0
Features
- Dependency injection ready (can also be used standalone, see below)
- Supports async calls.
Table of Contents
<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"> |
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 | Versions 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 was computed. 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. |
-
net7.0
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Http (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.