Skip to content

guillaume-dore/RiotGames

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interface library for the Riot Games Rest API

Generic badge Generic badge Generic badge GitHub license

Install

Currently not on Nuget, clone the repository and add reference. To make it work you need to set a new environment variable called RIOTGAMES_API_TOKEN with your API key to be able to launch Http requests or to provide an HttpClient already setted to the constructor which take an HttpClient as parameter.

Compatibility

The project is built with .NET Standard version 2.1, it support compatibility with .NET Core, Mono and Xamarin, refer to this link to get version compatibilities.

Usage

1. Standard usage:

To Set the location building the service the api key is provided by the environment variable:

RiotGames.Api.Http.LeagueService service = new LeagueService(LocationEnum.EUW1);
service.GetChallengerLeagueByQueue(QueueEnum.RANKED_SOLO_5X5);

The service is built with api key provided either the location need to be configurer here by the ConfigureLocation function who take LocationEnum as parameter:

RiotGames.Api.Http.LeagueService service = new LeagueService();
service.ConfigureLocation(LocationEnum.EUW1);
service.GetChallengerLeagueByQueue(QueueEnum.RANKED_SOLO_5X5);

The service is built with an HttpClient configured before, if the Environment variable isn't passed in the client sent as parameter then the environment variable is taken, if the baseAdress isn't correct either it is set to null and a call to ConfigureLocation is needed:

HttpClient client = new HttpClient();
client.BaseAdress = "https://euw1.api.riotgames.com/"
client.DefaultRequestHeaders.Add("X-Riot-Token", "YourApiKey");

RiotGames.Api.Http.LeagueService service = new LeagueService(client);
service.GetChallengerLeagueByQueue(QueueEnum.RANKED_SOLO_5X5);

Pass an unseted HttpClient instance and let the constructor configure it (notice that in that case the base address with location is not setted you will have to call ConfigureLocation):

HttpClient client = new HttpClient();
RiotGames.Api.Http.LeagueService service = new LeagueService(client);
service.ConfigureLocation(LocationEnum.EUW1);
service.GetChallengerLeagueByQueue(QueueEnum.RANKED_SOLO_5X5);
2. Dependency injection inside an ASP .Net Core project:

Inject the service in the ConfigureService method of the startup.cs class:

public void ConfigureServices(IServiceCollection services)
{
    /* Add Api implementation services */
    services.AddHttpClient<SummonerService>();
    services.AddHttpClient<LeagueService>();
    services.AddHttpClient<MatchService>();
}

Call ConfigureLocation before calling service method:

service.ConfigureLocation(LocationEnum.EUW1);
service.GetChallengerLeagueByQueue(QueueEnum.RANKED_SOLO_5X5);

License

For the moment, not under any licence.

About

Library interface for the Riot Games Rest API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages