Skip to content

[RiotCaller] League Of Legends API C# Portable Library- with different way

License

Notifications You must be signed in to change notification settings

msx752/RiotApiCaller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet nuget license

RiotCaller

Project for Riot Games API (League Of Legends game)

  • generic class and method were used
  • Ninject InSingletonScope was used
  • Repository Pattern included (half)
  • there is RiotCaller.Tests also there is ExampleProject in solution

Usage

defining riotgames api key

		ApiService.ApiKey="RiotGames API Key" //for service

or

		ApiService svc = new ApiService("[Riot API Key here]"); //classic defining
		Ranked data = svc.Api.GetStatsRanked("[summonerId]", "[region]");

using with Ninject

	..
		kernel.Bind<ApiService>().ToSelf().InSingletonScope().WithConstructorArgument("[Riot API Key here]");
	..

Examples

GetSummoner TYPE 1:
            	var summoner1 = LolApi.Api.GetSummoner("[summonerName]", [region]);
GetSummoner TYPE 2:
		//you can use this method in your solution wherever you want
       		var summoner2 = new RiotApiCaller<Summoner>(suffix.summonerByname);
     		summoner2.AddParam(param.summonerNames, new List<string>() { "[summonerName]" });
            	summoner2.AddParam(param.region, "[region]");
            	summoner2.CreateRequest();
GetStatsRanked TYPE 1:
        	 var ranked1 = LolApi.Api.GetStatsRanked("[summonerId]", "[region]");
GetStatsRanked TYPE 2:
		//you can use this method in your solution wherever you want
            	var ranked2 = new RiotApiCaller<Ranked>(suffix.statsRanked);
            	ranked2.AddParam(param.summonerId, "[summonerId]");
            	ranked2.AddParam(param.region, "[region]");
            	ranked2.AddParam(param.season, "[season]");
            	ranked2.CreateRequest();
GetStatsRanked TYPE 3:
            	var ranked3 = summoner1.GetStatsRanked();
GetStatsRanked TYPE 4:
            	Summoner summoner1 = LolApi.Api.GetSummoner("[summonerName]", "[region]");
            	var ranked4 =  SummonerExtensions.GetStatsRanked(summoner1);
     	 OR 
           	var ranked4 =  SummonerExtensions.GetStatsRanked(new Summoner() { Id = "[summonerId]" });

Coding Introduce

Type:Enum suffix

this struct helps for creating api url if you add new api method you must add new suffix

it has three attributes
  • ApiType Attribute
    -  (defining this apiurl is static OR is non-static, routing API SERVER URL)
  • apiVer Attribute
    -  (sometimes we need two keys, EXAMPLE: ( 'by-summoner/{summonerIds}' AND 'by-summoner/{summonerIds}/entry' )
    AND both of them use GetSummoner() ,so apiVer reference to BASE API URL like 'Summoner'
  • Value Attribute
    - this attribute separates and contains (suffix url) for each API
Type:Enum param

this struct helps replace to suffix url parameters if you add new suffix, you must add its parameter to param enum (if it has not already) Example: add new suffix name TEST with value, non-static, base api is league

        [ApiType(apiType.nonStatic)]
        [apiVer(apiVer.league)]
        [Value("by-summoner/{LeagueName}/entry?api_key={api_key}")]
        TEST

its parameter {LeagueName} if it has not in param which helps replace to suffix, you must add new value to param, like this 'LeagueName'

Use Of Caching

every ApiEndPoints can use memorycaching. (default value:FALSE)

            ApiService svc = new ApiService();
            Summoner data = svc.Api.GetSummoner("[summonerId]", "[region]", true); // TRUE: method is caching
            Ranked data = svc.Api.GetStatsRanked("[summonerId]", "[region]", null, true); //caching
            Champions data = svc.staticApi.GetChampions("[region]", "[language]", champData.all, true);//caching

Libraries used

-.NET MVC and dependency injection (not finished also half)

Development

if you have good idea, you can create pull request

License

This project is licensed under the MIT license.

Disclaimer

RiotCaller is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends. League of Legends and Riot Games are trademarks or registered trademarks of Riot Games , Inc. League of Legends © Riot Games, Inc.

About

[RiotCaller] League Of Legends API C# Portable Library- with different way

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages