Stastny.CRAPI
0.2.1
See the version list below for details.
dotnet add package Stastny.CRAPI --version 0.2.1
NuGet\Install-Package Stastny.CRAPI -Version 0.2.1
<PackageReference Include="Stastny.CRAPI" Version="0.2.1" />
paket add Stastny.CRAPI --version 0.2.1
#r "nuget: Stastny.CRAPI, 0.2.1"
// Install Stastny.CRAPI as a Cake Addin #addin nuget:?package=Stastny.CRAPI&version=0.2.1 // Install Stastny.CRAPI as a Cake Tool #tool nuget:?package=Stastny.CRAPI&version=0.2.1
C# wrapper for CR API
This C# wrapper was made to help people with using CR API. Wrapper is written in C# and can be used in any C# application.
You need developer key to use API. You can get the key by following instructions listed on CR API website
How to use this wrapper
You have to get your own API key. Get your API KEY here
Classes are divided into 3 groups:
- Main classes, like
Player
,Clan
andClashRoyale
. These classes have methods, that can be used to get some output (example:Player.GetPlayer(string tag)
method returns instance ofPlayer
). Instances of these classes have some basic information about object (likePlayer.name
) - Sub classes, like
PlayerClan
orClanBadge
. These classes are related to one of main classes -PlayerClan
is related to classPlayer
, orClanBadge
is related to classClan
. These classes contains additional information. For examplePlayer.clan
returnsPlayClan
class, that contains summary of player's clan (information that you can get from ingame profile window, detailed information are inClan
class) - Independent classes, like
Card
. These classes are something between Main classes and Sub classes. They are independent, but you cannot get them directly. They are returned alongside with some Main Class. For example,Player
class containsdeck
property, that is array ofCard
.
Note: All classes are in namespace
CRAPI
To start, initialize Wrapper
class. Wrapper wr = new Wrapper(your_dev_key);
. You can get clans and players by calling methods on Wrapper class. See example usage.
Example usage
You have to add using:
using CRAPI;
// Initialize wrapper with your dev key
Wrapper wr = new Wrapper("your dev key");
// Get player with ID 80RGVCV9C
Player player = wr.GetPlayer("80RGVCV9C");
// Get clan with ID 22Y802
Clan clan = wr.GetClan("22Y802");
Console.WriteLine(player.name);
Console.WriteLine(clan.name);
// Write cards in player's deck
foreach (Card card in player.currentDeck)
Console.WriteLine(card);
Console.WriteLine("\n");
// Write best player's name and best clan's name
Console.WriteLine(wr.GetTopPlayers()[0]);
Console.WriteLine(wr.GetTopClans()[0]);
Documentation
Documentation is still in TODO phase. Everything you need is commented inside classes. Open .cs
files to see code.
Exceptions
When something goes wrong, this wrapper throws an exception. This exception is thrown ONLY in .Get
methods, that access API. The exception thrown is WebException
. This exception means,
that either user don't have connection to the Internet, or something inside API gone wrong (their servers may be down).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Newtonsoft.Json (>= 10.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.
Version | Downloads | Last updated |
---|---|---|
0.7.3 | 1,144 | 8/12/2018 |
0.7.2 | 926 | 8/9/2018 |
0.7.1 | 1,089 | 6/3/2018 |
0.7.0 | 1,039 | 5/29/2018 |
0.6.3 | 1,025 | 5/29/2018 |
0.6.2 | 1,053 | 5/23/2018 |
0.6.1 | 1,013 | 5/12/2018 |
0.6.0 | 1,034 | 5/12/2018 |
0.5.5 | 1,034 | 3/26/2018 |
0.5.2 | 1,011 | 3/3/2018 |
0.5.1 | 1,019 | 3/1/2018 |
0.5.0 | 1,051 | 2/27/2018 |
0.4.3 | 1,028 | 2/19/2018 |
0.4.1 | 1,075 | 2/3/2018 |
0.4.0 | 1,034 | 1/30/2018 |
0.3.6 | 1,124 | 1/24/2018 |
0.3.4 | 1,027 | 1/15/2018 |
0.3.3 | 1,136 | 1/11/2018 |
0.3.2 | 1,373 | 1/5/2018 |
0.3.0 | 1,131 | 1/2/2018 |
0.2.9 | 1,043 | 1/1/2018 |
0.2.6 | 1,129 | 12/26/2017 |
0.2.5 | 1,083 | 12/26/2017 |
0.2.1 | 985 | 12/25/2017 |
0.2.0 | 978 | 12/25/2017 |
0.1.0 | 1,063 | 11/30/2017 |
Added new features and fixed compatibility with API. Added auth. Added project url and summary.