RiotSharp 2.5 released

November 20, 2016 - RiotSharp, release

RiotSharp 2.5 has been released for a couple of days, this post will list what’s new.

Website

First and foremost, there is a new website available at https://benfradet.github.io/RiotSharp. For the moment, it contains a copy of the readme and a browsable API documentation.

The plan is to extend it in order to have a small guide for each supported API. You can track progress for the articles in issue 266.

Champion mastery API

During the 2.5 release cycle, we added support for the champion mastery API. As a result you can now query the champion mastery for a summoner:

// We instantiate a static API to get the champion id of Lucian
var staticApi = StaticRiotApi.GetInstance("YOUR_API_KEY");
// We retrieve Lucian's id through the static API's GetChampions method
var lucianId = staticApi.GetChampions(Region.na).Champions["Lucian"].Id;

var api = RiotApi.GetInstance("YOUR_API_KEY");
// This is the summoner ID for which I want to know his/her Lucian's mastery
var summonerId = 57039082;
// We retrieve the champion mastery for this summoner and this champion
var mastery = api.GetChampionMastery(Platform.NA1, summonerId, lucianId);
Console.WriteLine(mastery.ChampionLevel);

You can also get all the champion masteries for a particular summoner:

var masteries = api.GetAllChampionsMasteryEntries(Platform.NA1, summonerId);
foreach (var m in masteries)
{
  Console.WriteLine(m.ChampionId + ": " + m.ChampionLevel);
}

You can get the sum of all champion masteries for a summoner as well:

var sum = api.GetTotalChampionMasteryScore(Platform.NA1, summonerId);
Console.WriteLine(sum);

Finally, you can get the top N champion masteries for a particular summoner:

var n = 5;
var top5Masteries = api.GetTopChampionsMasteryEntries(Platform.NA1, summonerId, n);
foreach (var m in top5Masteries)
{
  Console.WriteLine(m.ChampionId + ": " + m.ChampionLevel);
}

Of course, there are also async versions of each method.

Coverage for this endpoint has been written by Ostrea, thanks a lot to him!

There is also an issue to rename a few methods related to this endpoint if you want to help out.

Taking care of some of the endpoints’ arbitrary limits

If you’re an heavy user of the API, you know that some endpoints restrict the maximum number of ids you can query. This is notably the case for:

Suppose that you have 50 summoner ids and you want to know the name associated with each id. Before 2.4, you had to split you 50 ids in two sets (one of 40 and one of 10 for example) and make two calls to the GetSummonerNames method. As of 2.5, we’ll take care of the dirty work for you and, if you give us more than 40 summoner ids, make the appropriate number of call to the API: 2 in the case of 50 summoner ids and give you back 50 summoner names in one call.

Thanks a lot to Philipp Widra for the idea and the implementation!

Cache languages and maps

Before 2.5, there were some stuff in the static API that RiotSharp didn’t cache. This was the case for:

Thanks to the work of Shrayas Rajagopal this is not the case anymore!

What’s next?

For 2.6, we’re planning on mocking a lot of unit tests because the API hasn’t always been reliable for us. This is currently being done by Marshall Todt in #253.

As mentioned earlier, we also want to make the website better by providing small tutorials for the differents APIs.

If you want to contribute, check the up-for-grabs label!