Kunc.RiotGames.Api
0.13.0
Prefix Reserved
dotnet add package Kunc.RiotGames.Api --version 0.13.0
NuGet\Install-Package Kunc.RiotGames.Api -Version 0.13.0
<PackageReference Include="Kunc.RiotGames.Api" Version="0.13.0" />
<PackageVersion Include="Kunc.RiotGames.Api" Version="0.13.0" />
<PackageReference Include="Kunc.RiotGames.Api" />
paket add Kunc.RiotGames.Api --version 0.13.0
#r "nuget: Kunc.RiotGames.Api, 0.13.0"
#addin nuget:?package=Kunc.RiotGames.Api&version=0.13.0
#tool nuget:?package=Kunc.RiotGames.Api&version=0.13.0
Kunc.RiotGames.Api
How to Use
using Kunc.RiotGames.Api;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection()
.AddRiotGamesApi(c => c.ApiKey = "RGAPI-...")
.BuildServiceProvider();
IRiotGamesApi api = services.GetRequiredService<IRiotGamesApi>();
// or
IRiotGamesApi api = RiotGamesApi.Create(c => c.ApiKey = "RGAPI-...");
var account = await api.RiotAccountV1.GetAccountByRiotIdAsync(Regions.EUROPE, "AoshiW#IRON");
Console.WriteLine($"Account: {account.GetRiotId()}");
var summoner = await api.LolSummonerV4.GetSummonerByPuuidAsync(Regions.EUN1, account.Puuid);
Console.WriteLine();
Console.WriteLine("Ranks:");
var entries = await api.LolLeagueV4.LeagueEntriesForSummonerAsync(Regions.EUN1, summoner.Puuid);
foreach (var entry in entries)
{
Console.WriteLine($"{entry.QueueType}: {entry.ToRank()}");
}
If you created an instance of RiotGamesApi
using the RiotGamesApi.Create(...)
method, then save the instance and reuse it. If you keep creating new instances then some features may not work properly.
Features
Rate limiting
The rate limiter is automatically set according to your api key.
Caching
The HybridCache
is used as the caching provider, so by default it is only cached in memory, if you want an out-of-process cache, register IDistributedCache service to ServiceCollection
.
It's also disabled by default in this project, so you have to enable it first. (Why is it disabled? Short answer: there is no universal setting, so it is better to let everyone set it up themselves.)
How to enable caching:
- Add some IDistributedCache service
- you can enable it globally for all endpoints by setting
DefaultCacheEntryOptions
. - you can enable/modify it only for some endpoints using
MethodCacheEntryOptions[]
(per endpoint setting takes precedence over global)
// optionally adding some IDistributedCache .. for example Redis
Services.AddStackExchangeRedisCache(o =>
{
o.Configuration = "connection string";
});
// configuration
Services.AddRiotGamesApi(c =>
{
c.ApiKey = "RGAPI-...";
// global
c.DefaultCacheEntryOptions = new HybridCacheEntryOptions() { ... };
// per endpoint (the endpoint url is used as the key)
c.MethodCacheEntryOptions["/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}"] = new HybridCacheEntryOptions() { ... };
})
Other useful things
Customizing JSON deserialization
The library allows to access the JsonSerializerOptions
instance which is used for deserializing JSON into a class.
So if there is some problem with the deserialization (e.g.: the property is of type int
but Riot returns a number in decimal format: 5.0
),
you can change it with:
Services.AddRiotGamesApi>(c =>
{
c.ApiKey = "RGAPI-...";
c.JsonSerializerOptions = new JsonSerializerOptions()
{
Converters = { new DoubleToIntConverter() }
};
});
Disclaimer
Kunc.RiotGames.Api
isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.
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 is compatible. 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. |
-
net8.0
- Kunc.RiotGames.Core (>= 0.13.0)
- Microsoft.Extensions.Caching.Hybrid (>= 9.5.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.5)
- Microsoft.Extensions.Http (>= 9.0.5)
- Microsoft.Extensions.Http.Resilience (>= 9.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Options (>= 9.0.5)
- System.Threading.RateLimiting (>= 9.0.5)
-
net9.0
- Kunc.RiotGames.Core (>= 0.13.0)
- Microsoft.Extensions.Caching.Hybrid (>= 9.5.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.5)
- Microsoft.Extensions.Http (>= 9.0.5)
- Microsoft.Extensions.Http.Resilience (>= 9.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- Microsoft.Extensions.Options (>= 9.0.5)
- System.Threading.RateLimiting (>= 9.0.5)
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.13.0 | 217 | 5/15/2025 |
0.12.0 | 139 | 4/18/2025 |
0.11.0 | 170 | 3/22/2025 |
0.10.0 | 154 | 3/11/2025 |
0.9.0 | 121 | 2/25/2025 |
0.8.0 | 119 | 2/20/2025 |
0.7.0 | 131 | 2/12/2025 |
0.6.0 | 107 | 1/22/2025 |
0.5.0 | 108 | 1/17/2025 |
0.4.0 | 110 | 11/29/2024 |
0.1.4 | 141 | 6/28/2024 |
0.1.3 | 131 | 6/18/2024 |
0.1.2 | 132 | 6/2/2024 |
0.1.1 | 138 | 4/24/2024 |