Search code examples
javariot-games-api

Fetch summoner name from id


I am currently using the java-version of the Riot api, made by rithms, (https://github.com/rithms/riot-api-java) and I am trying to receive the name of a champion, as I am currently "just" able to get the id.

RankedStats rankedStats = api.getRankedStats(api.getSummonerByName("AscendedKitten").getId());

Now, when printing out the results of

rankedStats.getChampions();

it will (of course) return the Ids. I noticed that

net.rithms.riot.dto.Champion.Champion

has a methode returning the name, but (because I am failing at reading the Documentation) I haven't found out how to cast / get an instance of the object yet.

I am sorry for the basic-question, and I hope you don't have too much trouble trying to help me :3

Thanks in advance!


Solution

  • Use the RiotApi class' getDataChampion(Region region, int id) method, then use the getName() method on the champion it returns.