CocApi 0.18.0-alpha
See the version list below for details.
dotnet add package CocApi --version 0.18.0-alpha
NuGet\Install-Package CocApi -Version 0.18.0-alpha
<PackageReference Include="CocApi" Version="0.18.0-alpha" />
paket add CocApi --version 0.18.0-alpha
#r "nuget: CocApi, 0.18.0-alpha"
// Install CocApi as a Cake Addin #addin nuget:?package=CocApi&version=0.18.0-alpha&prerelease // Install CocApi as a Cake Tool #tool nuget:?package=CocApi&version=0.18.0-alpha&prerelease
CocApiLibrary
This .NET Standard 2.1 library will provide responses from developer.clashofclans.com.
CocApiConsoleTest
The test program shows you how to set up the library.
The library can grab SC API objects on command.
It can also automatically keep these objects up to date by polling the API.
When an object changes, it will fire an event which you can subscribe to.
You may optionally provide an ILogger to observe what the library is doing.
The test program will output the following:<br/><br/>
If you choose to keep the objects up to date, the library will constantly write to the ILogger.
Of course, the ILogger is in your program, so you can choose what to print.
CocApi
The CocApi class is the entry point to this library. You likely want this class to be a singleton that lives for the life of your application. This class is disposable, don't forget to call Dispose when you end your applicaiton. This program has the potential to consume a lot of memory.
CocApiConfiguration
Use this to configure the CocApi class. This class can control how often your SC API token is used. You can also control how long a downloaded object is considered good for. The default values are very conservative just in case the SC API key you provide is used for something else. This is to avoid rate limiting your key. If your key is only used in CocApi, you can make the time spans much shorter. The API allows about 10 requests a second per key.
WebResponse
This is an internal static class. If it prints to the ILogger, that indicates that the library is polling the API.
UpdateService
This is an internal class. If it prints to the ILogger, it is updating an object. If the object being updated is not expired, it will not ask the WebResponse class to poll the API.
ICurrentWarAPIModel
This interface is implemented by CurrentWarAPIModel and LeagueWarAPIModel. The only difference is LeagueWarAPIModel has a WarTag property, and the WarType enum will be SCCWL. When CocApi returns an ICurrentWarAPIModel, you can cast it to the appropriate type when necessary. LeagueWarAPIModel also inherits from CurrentWarAPIModel. If you have to cast, ensure you start with LeagueWarAPIModel.
IWar
This empty interface is implemented by ICurrentWarAPIModel and the NotInWar model. The library will never return an ICurrentWarAPIModel with state = notInWar.
ILeagueGroup
This empty interface is implemented by LeagueGroupApiModel and LeagueGroupNotFound. Clans that are not in CWL war will return a LeagueGroupNotFound.
Extensions
The static Extensions class contains some things that may be useful, especially for Discord bots. DiscordSafe will strip Discord markup characters from a given string. LeftToRight will force characters to display left to right. This is especially helpful while making tables. ToDateTime will convert SC API date time objects to C# DateTime, though the library already handles this when downloading your object.
Outages
When the API goes down, the IsAvailableChanged event will fire. CocApi will not stop trying to update expired objects unless you tell it to in this event. When an outage is detected, it will poll the API every five seconds to see if the server is back up. If an error occurs while watching clans, a CrashDetected event will fire. You may handle it by StartWatchingClans, or any other means you wish.
Issues
If you have problems finding one of the required nuget packages, add https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json as a source.</br></br> If the objects update too slow or two fast, modify the properties of the CocApiConfiguration. TokenObject rate limits are bad. TokenObject preemptive rate limits are okay, though it does indicate the library is updating as fast as the TokenTimeOut allows.
Entity Framework
These classes should translate to working tables with little or no effort. Paste the below code into your OnModelCreating.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//composite keys
modelBuilder.Entity<ClanLabelAPIModel>().HasKey(p => new { p.Id, p.ClanTag });
modelBuilder.Entity<AchievementAPIModel>().HasKey(p => new { p.Name, p.VillageTag });
modelBuilder.Entity<SpellAPIModel>().HasKey(p => new { p.Name, p.VillageTag });
modelBuilder.Entity<TroopAPIModel>().HasKey(p => new { p.Name, p.VillageTag, p.Village });
modelBuilder.Entity<LegendLeagueResultAPIModel>().HasKey(p => new { p.Id, p.VillageTag, p.Village });
modelBuilder.Entity<VillageLabelAPIModel>().HasKey(p => new { p.Id, p.VillageTag });
modelBuilder.Entity<AttackAPIModel>().HasKey(p => new { p.WarId, p.Order });
//define one-to-zero(or one) relationship between villages and legends league
modelBuilder.Entity<VillageAPIModel>()
.HasOne(p => p.LegendStatistics)
.WithOne(p => p!.Village!)
.HasForeignKey<LegendLeagueStatisticsAPIModel>(p => p.VillageTag)
.OnDelete(DeleteBehavior.Restrict);
//define one-to-one relationship between current war and flags
modelBuilder.Entity<CurrentWarAPIModel>()
.HasOne(p => p.Flags)
.WithOne(p => p.CurrentWarAPIModel)
.HasForeignKey<CurrentWarFlagsModel>(p => p.WarId);
}
Disclaimer
This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell's Fan Content Policy.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.EntityFrameworkCore (>= 3.1.0-preview2.19525.5)
- Microsoft.Extensions.DependencyInjection (>= 3.1.0-preview2.19525.4)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.0-preview2.19525.4)
- System.Net.Http (>= 4.3.4)
- System.Net.Requests (>= 4.3.0)
- System.Reflection.Emit.Lightweight (>= 5.0.0-alpha1.19519.4)
- System.Text.Json (>= 5.0.0-alpha1.19519.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CocApi:
Package | Downloads |
---|---|
CocApi.Cache
Caches response from the Clash of Clans API. |
|
CocApi.Rest
A wrapper for the Clash of Clans API |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.12.0 | 42 | 11/23/2024 |
2.11.1 | 501 | 12/13/2023 |
2.5.0 | 882 | 5/28/2023 |
2.4.0 | 236 | 5/21/2023 |
2.0.0 | 576 | 5/7/2023 |
2.0.0-preview1.17.9 | 108 | 1/19/2023 |
2.0.0-preview1.17.4 | 136 | 10/9/2022 |
2.0.0-preview1.17.2 | 104 | 10/5/2022 |
2.0.0-preview1.14.7 | 132 | 5/7/2022 |
2.0.0-preview1.14.1 | 106 | 5/1/2022 |
2.0.0-preview1.14.0 | 114 | 5/1/2022 |
1.14.6 | 361 | 12/11/2021 |
1.14.5 | 336 | 10/24/2021 |
1.14.4 | 380 | 10/8/2021 |
1.14.3 | 413 | 10/6/2021 |
1.14.2 | 403 | 9/30/2021 |
1.14.1 | 346 | 9/25/2021 |
1.14.0 | 389 | 9/25/2021 |
1.13.0 | 362 | 9/18/2021 |
1.12.0 | 464 | 9/11/2021 |
1.11.5 | 451 | 9/11/2021 |
1.11.4 | 447 | 7/17/2021 |
1.11.3 | 361 | 7/14/2021 |
1.11.2 | 359 | 7/14/2021 |
1.11.1 | 372 | 7/14/2021 |
1.11.0 | 375 | 7/14/2021 |
1.10.3 | 361 | 7/11/2021 |
1.10.2 | 386 | 6/23/2021 |
1.10.1 | 389 | 6/17/2021 |
1.10.0 | 373 | 6/16/2021 |
1.9.1 | 413 | 5/2/2021 |
1.9.0 | 403 | 5/2/2021 |
1.8.0 | 433 | 4/25/2021 |
1.7.1 | 358 | 4/13/2021 |
1.7.0 | 358 | 4/10/2021 |
1.6.0 | 387 | 4/8/2021 |
1.5.2 | 367 | 4/12/2021 |
1.5.1.1 | 384 | 3/14/2021 |
1.5.1 | 332 | 3/13/2021 |
1.5.0.2 | 355 | 3/10/2021 |
1.5.0.1 | 380 | 2/28/2021 |
1.5.0 | 363 | 2/20/2021 |
1.4.0.1 | 377 | 2/17/2021 |
1.4.0 | 467 | 2/7/2021 |
1.4.0-preview.1.1.0.0 | 170 | 1/25/2021 |
1.4.0-preview.1.0.0.0 | 181 | 1/24/2021 |
1.3.2-preview.1.0.1.7 | 249 | 1/2/2021 |
1.3.2-preview.1.0.1.5 | 229 | 1/1/2021 |
1.3.2-preview.1.0.1.4 | 298 | 1/1/2021 |
1.3.2-preview.1.0.1.2 | 185 | 12/27/2020 |
1.3.2-preview.1.0.1.1 | 197 | 12/26/2020 |
1.3.2-preview.1.0.1 | 215 | 12/14/2020 |
1.3.2-preview.1.0.0.1 | 220 | 12/26/2020 |
1.3.2-preview.1.0.0 | 245 | 12/13/2020 |
1.3.1.4 | 647 | 12/13/2020 |
1.3.1.3 | 660 | 12/12/2020 |
1.3.1.2 | 632 | 12/12/2020 |
1.3.1.1 | 679 | 12/12/2020 |
1.3.1 | 529 | 12/12/2020 |
1.3.0 | 564 | 12/12/2020 |
1.2.0 | 602 | 12/11/2020 |
1.1.1.5 | 644 | 12/9/2020 |
1.1.1.4 | 579 | 12/8/2020 |
1.1.1 | 1,053 | 12/6/2020 |
1.1.0 | 686 | 12/5/2020 |
1.0.0 | 589 | 11/26/2020 |
0.43.0-alpha | 405 | 5/25/2020 |
0.42.0-alpha | 349 | 5/20/2020 |
0.41.0-alpha | 422 | 5/18/2020 |
0.40.0-alpha | 334 | 5/12/2020 |
0.39.0-alpha | 349 | 5/12/2020 |
0.38.0-alpha | 382 | 5/11/2020 |
0.37.0-alpha | 343 | 5/9/2020 |
0.36.0-alpha | 362 | 5/8/2020 |
0.35.0-alpha | 345 | 5/8/2020 |
0.34.0-alpha | 338 | 5/7/2020 |
0.33.0-alpha | 362 | 5/6/2020 |
0.32.0-alpha | 367 | 5/5/2020 |
0.31.0-alpha | 330 | 5/5/2020 |
0.30.0-alpha | 345 | 5/3/2020 |
0.29.0-alpha | 348 | 4/19/2020 |
0.28.0-alpha | 344 | 4/19/2020 |
0.27.0-alpha | 246 | 4/19/2020 |
0.26.0-alpha | 320 | 3/18/2020 |
0.25.0-alpha | 327 | 2/23/2020 |
0.24.0-alpha | 331 | 1/26/2020 |
0.23.0-alpha | 276 | 1/7/2020 |
0.22.0-alpha | 258 | 1/5/2020 |
0.21.0-alpha | 269 | 12/15/2019 |
0.20.0-alpha | 252 | 11/27/2019 |
0.19.0-alpha | 269 | 11/24/2019 |
0.18.0-alpha | 287 | 11/23/2019 |
0.17.0-alpha | 256 | 11/11/2019 |
Initial Release
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
Use this feed to get Reflection while this is in prerelease.