LoLAPI class

On this page you will find the list of methods available for the LoLAPI class. Dispite the name, LoLAPI is not only for League of Legends, but includes all the methods from the original Riot Games API.

The majority of methods in this class are a direct implementation of Riot Games API methods, while the others are extras made to add features and (hopefully) simplify your experience with this library. Those that return the result of an API method always return an instance of a subclass of RiotApiResponse.

class async_riot_api.LoLAPI

Main class to interact with the API. Offers async methods corresponding to API methods and more.

It is important to notice that this implementation is exception-free, not meaning that it’s impossible to make mistake, but meaning that errors returned by the API are not raised as exceptions. Instead, they are returned as RiotApiError, containing information about the error. To distinguish between a successful response and an error, you can easily use the object as a boolean expression:

summoner = await api.get_account_by_puuid(puuid)
if not summoner:
    print(f'Error with status code {summoner.status_code}: {summoner.message}')
else:
    print(summoner.to_string(sep = '|   '))

Another important thing to know is that some methods are simple functions, not coroutines, meaning that they only work with offline data without making any request. They are usually static methods.

Parameters
  • api_key (str) – your API token

  • region (str) – region you want to use

  • routing_value (str) – one among ‘AMERICA’, ‘ASIA’, ‘ESPORTS’, ‘EUROPE’ or ‘SEA. Needed for some API calls, depends on region

  • debug (bool) – if you want the LoLAPI object to print the url of every request made

async get_account_by_puuid(puuid: str) async_riot_api.types.AccountDto

To get an account given its puuid.

Original method.

Parameters

puuid (str) – puuid of the account

Returns

account data

Return type

AccountDto

async get_account_by_game_name(game_name: str, tag_line: str) async_riot_api.types.AccountDto

To get an account given its name and tag line.

Original method.

Parameters
  • game_name (str) – in-game name of the account

  • tag_line (str) – no documentation found

Returns

account data

Return type

AccountDto

async get_active_shards(game: str, puuid: str) async_riot_api.types.ActiveShardDto

No documentation found.

Original method.

Parameters
  • game (str) – one of ‘val’ or ‘lor’

  • puuid (str) – puuid of the account

Returns

shard data

Return type

ActiveShardDto

async get_masteries(summoner_id: str) List[async_riot_api.types.ChampionMasteryDto]

Get the list of masteries for a summoner.

Original method.

Parameters

summoner_id (str) – summoner ID

Returns

list of masteries for the given summoner

Return type

List[ChampionMasteryDto]

async get_champion_mastery(summoner_id: str, champion_id: int) async_riot_api.types.ChampionMasteryDto

Get a specific champion mastery for the given summoner.

Original method.

Parameters
  • summoner_id (str) –

  • champion_id (int) –

Returns

champion mastery for given summoner and champion

Return type

ChampionMasteryDto

async get_mastery_score(summoner_id: str) int

Get the total mastery score of a summoner. Mastery score is given by the sum of individual champion mastery levels.

Original method.

Parameters

summoner_id (str) –

Returns

mastery score of the given summoner

Return type

int

async get_champion_rotation() async_riot_api.types.ChampionInfo

Get champion rotations, including free-to-play and low-level free-to-play rotations.

Original method.

Returns

information about champion rotations

Return type

ChampionInfo

async get_clash_players_by_summoner_id(summoner_id: str) List[async_riot_api.types.PlayerDto]

Get a list of active Clash players for a given summoner ID. If a summoner registers for multiple tournaments at the same time (e.g., Saturday and Sunday) then both registrations would appear in this list.

Original method.

Parameters

summoner_id (str) –

Returns

list of players

Return type

List[PlayerDto]

async get_clash_team_by_id(team_id: str) async_riot_api.types.ClashTeamDto

Get a clash team by its ID.

Original method.

Parameters

team_id (str) –

Returns

information about the team

Return type

TeamDto

async get_clash_tournaments() List[async_riot_api.types.TournamentDto]

Get all active or upcoming tournaments.

Original method.

Returns

list of tournaments

Return type

List[TournamentDto]

async get_clash_tournament_by_team_id(team_id: str) async_riot_api.types.TournamentDto

Get tournament by team ID.

Original method.

Parameters

team_id (str) –

Returns

information about tournament

Return type

TournamentDto

async get_clash_tournament_by_id(tournament_id: int) async_riot_api.types.TournamentDto

Get info about a clash tournament by its ID.

Original method.

Parameters

tournament_id (int) –

Returns

information about the tournament

Return type

TournamentDto

async get_summoners_by_league_exp(queue: str, tier: str, division: str, page: int = 1) Set[async_riot_api.types.LeagueEntryDTO]

This is an experimental (and personally untested) endpoint added as a duplicate of get_summoners_by_league(), but it also supports the apex tiers (Challenger, Grandmaster, and Master).

Original method..

Parameters
  • queue (str) – one among ‘RANKED_SOLO_5x5’, ‘RANKED_TFT’, ‘RANKED_FLEX_SR’ or ‘RANKED_FLEX_TT’

  • tier (str) – rank tier, between ‘IRON’ and ‘CHALLENGER’

  • division (str) – rank division, between ‘I’ and ‘IV’ (in roman numbers)

  • page (int) – page to select, starting from 1. Limited based on the number of entries, it’s suggested to iter until results are found

Returns

set of summoners for the requested queue, tier and division

Return type

Set[LeagueEntryDTO]

async get_challenger_leagues(queue: str) async_riot_api.types.LeagueListDTO

Get the list of challengers.

Original method.

Parameters

queue (str) – one among ‘RANKED_SOLO_5x5’, ‘RANKED_FLEX_SR’ or ‘RANKED_FLEX_TT’

Returns

set of challengers

Return type

LeagueListDTO

async get_league(summoner_id: str) Set[async_riot_api.types.LeagueEntryDTO]

Get the set of league entries for a given summoner.

Original method.

Parameters

summoner_id (str) –

Returns

information about their ranks in every queue

Return type

Set[LeagueEntryDTO]

async get_summoners_by_league(queue: str, tier: str, division: str, page: int = 1) Set[async_riot_api.types.LeagueEntryDTO]

Get the list of summoners that are currently in the given rank of the given queue. Only supports non-apex tiers. To get information about apex tiers, look at get_summoners_by_league_exp().

Original method.

Parameters
  • queue (str) – one among ‘RANKED_SOLO_5x5’, ‘RANKED_FLEX_SR’ or ‘RANKED_FLEX_TT’

  • tier (str) – rank tier, between ‘IRON’ and ‘DIAMOND’

  • division (str) – rank division, between ‘I’ and ‘IV’ (in roman numbers)

  • page (int) – page to select, starting from 1. Limited based on the number of entries, it’s suggested to iter until results are found

Returns

set of summoners for the requested queue, tier and division

Return type

Set[LeagueEntryDTO]

async get_grand_master_leagues(queue: str) async_riot_api.types.LeagueListDTO

Same as get_challenger_leagues(), but for grand masters.

Original method.

async get_leagues(league_id: str) async_riot_api.types.LeagueListDTO

Get the list of summoners in the given league by its ID.

Original method.

Parameters

league_id (str) –

Returns

list of summoners currently in the given league

Return type

LeagueListDTO

async get_master_leagues(queue: str) async_riot_api.types.LeagueListDTO

Same as get_challenger_leagues(), but for masters.

Original method.

async get_platform_data_v3() async_riot_api.types.ShardStatus

DEPRECATED Get information about LoL server status.

Original method.

Returns

the current server status

Return type

ShardStatus

async get_platform_data() async_riot_api.types.PlatformDataDto

Get information about LoL server status.

Original method.

Returns

the current LoL server status

Return type

PlatformDataDto

async get_lor_matches(puuid: str) List[str]

Get the list of LoR matches played by the given summoner. Often used before get_lor_match().

Original method.

Parameters

puuid (str) –

Returns

list of match IDs sorted by recent

Return type

List[str]

async get_lor_match(match_id: str) async_riot_api.types.LorMatchDto

Get information about the given LoR match. Often used after get_lor_matches().

Original method.

Parameters

match_id (str) –

Returns

useful information about the given LoR match and its players

Return type

LorMatchDto

async get_lor_leaderboards() async_riot_api.types.LorLeaderboardDto

Get the list of players in Master tier.

Original method.

Returns

players in LoR Master tier

Return type

LorLeaderboardDto

async get_lor_status() async_riot_api.types.PlatformDataDto

Get information about LoR servers status.

Original method.

Returns

the current LoR server status

Return type

PlatformDataDto

async get_matches(puuid: str, *, startTime: Optional[int] = None, endTime: Optional[int] = None, queue: Optional[int] = None, type: Optional[str] = None, start: int = 0, count: int = 20) List[str]

Get the list of LoL matches played by the given summoner. Often used before get_match(). Allows filtering by start/end time, queue and type of match.

Original method.

Parameters
  • puuid (str) –

  • startTime (int) – epoch timestamp in seconds. The matchlist started storing timestamps on June 16th, 2021. Any matches played before June 16th, 2021 won’t be included in the results if the startTime filter is set

  • endTime (int) – epoch timestamp in seconds

  • queue (int) – queue filter for the list. Queue IDs can be found here. Queue and type parameters are mutually inclusive

  • type (str) – one among ‘ranked’, ‘normal’, ‘tourney’ or ‘tutorial’

  • start (int) – start index, starting from 0. Default 0

  • count (int) – number of match IDs to return. Must be in the range 0-100. Default 20

Returns

list of match IDs sorted by recent

Return type

List[str]

async get_match(match_id: str) async_riot_api.types.MatchDto

Get information about the given LoL match. Often used after get_matches().

Original method.

Parameters

match_id (str) –

Returns

useful information about the given LoR match and its players

Return type

MatchDto

async get_timeline(match_id: str) async_riot_api.types.MatchTimelineDto

Get additional information about a match, ordered by time, organized in “frames”. This kind of response contains information about items bought, skills unlocked, summoners position and more. Unfortunately on the original doc this method is not documented at all. Not even the return type is documented except for its name, so anything about this method comes from experimentation.

Original method.

Parameters

match_id (str) –

Returns

more data about the match, ordered by time

Return type

MatchTimelineDto

async get_active_games(summoner_id: str) async_riot_api.types.CurrentGameInfo

Get information about the active game played by the given summoner.

IMPORTANT This method returns a RiotApiError if the summoner is not in a game.

Original method.

Parameters

summoner_id (str) –

Returns

information about the current match and its players, if exists

Return type

CurrentGameInfo

Get a list of games that are currently being played. It is not clear to me what are the criteria for a game to be listed here, and I haven’t found anything on the documentation. Anyway, this method could be useful for those who need to harvest a large amount of data from real matches.

Original method.

Returns

games that are currently being played

Return type

FeaturedGames

async get_summoner_by_account_id(account_id: str) async_riot_api.types.SummonerDTO

Get information about a summoner by its account ID. You can get an account ID using get_summoner_by_name().

Original method.

Parameters

account_id (str) –

Returns

basic information about the summoner

Return type

SummonerDTO

async get_summoner_by_name(summoner_name: str) async_riot_api.types.SummonerDTO

Probably the first method you will need to call at the beginning of any program involving Riot Games API. This method allows accessing basic information about a summoner given its name. With this information you will be able to use any other method requiring a summoner ID, account ID or puuid.

Original method.

Parameters

summoner_name (str) – name of the summoner you are looking for

Returns

basic information about the summoner

Return type

SummonerDTO

async get_summoner_by_puuid(puuid: str) async_riot_api.types.SummonerDTO

Get information about a summoner by its puuid. You can get a puuid using get_summoner_by_name().

Original method.

Parameters

puuid (str) –

Returns

basic information about the summoner

Return type

SummonerDTO

async get_summoner_by_summoner_id(summoner_id: str) async_riot_api.types.SummonerDTO

Get information about a summoner by its summoner ID. You can get a summoner ID using get_summoner_by_name().

Original method.

Parameters

summoner_id (str) –

Returns

basic information about the summoner

Return type

SummonerDTO

async get_nth_match(puuid: str, n: int = 0) Optional[async_riot_api.types.MatchDto]

Directly get information about a summoner’s match given its index, starting from 0. This is just a shorcut for get_matches() and get_match().

Parameters
  • puuid (str) – puuid of the summoner

  • n (int) – index of the match, starting from 0. Default 0

Returns

information about the match, if exists. None otherwise

Return type

Optional[MatchDto]

async get_last_match(puuid: str) Optional[async_riot_api.types.MatchDto]

Directly get information about a summoner’s last match. This is just a shortcut for get_nth_match().

Parameters

puuid (str) –

Returns

same as get_nth_match()

Return type

Optional[MatchDto]

async get_solo_league(summoner_id: str) Optional[async_riot_api.types.LeagueEntryDTO]

Directly get information about a summoner’s SOLO rank.

Parameters

summoner_id (str) –

Returns

given summoner’s SOLO rank, if exists.

Return type

LeagueEntryDTO

async get_flex_league(summoner_id: str) Optional[async_riot_api.types.LeagueEntryDTO]

Same as get_solo_league(), but FLEX.

Parameters

summoner_id (str) –

Returns

given summoner’s FLEX rank, if exists.

Return type

LeagueEntryDTO

static get_profile_icon_url(icon_id: int) str

Returns the url to the given icon.

IMPORTANT: no check will be made about data existence, meaning that passing a wrong icon_id will simply result in a broken url. No error will be raised.

Parameters

icon_id (int) –

Returns

url to the icon

Return type

str

static get_champion_image_url_from_id(champ_id: int, skin: int = 0, type: str = 'splash') str

Returns the url to the image for the given champion, skin and type.

IMPORTANT: no check will be made about data existence, meaning that passing a wrong champ_id, skin or type will simply result in a broken url. No error will be raised.

Parameters
  • champ_id (int) – champion ID, corresponding to ShortChampionDD.int_id

  • skin (int) – number of the requested skin, starting from 0 for the default skin. Default 0

  • type (str) – type of image. Can be ‘splash’ or ‘loading’. Default ‘splash’

Returns

url to the image

Return type

str

static compute_champion_from_similar_name(search_name: str) async_riot_api.types.ShortChampionDD

Computes the most similar champion to the given name. The similarity computation is made using this library.

Parameters

search_name (str) – name to search

Returns

champion whose name is the most similar to the given one

Return type

ShortChampionDD

static compute_language(search_language: str) str

Computes the most similar language available from this list. The similarity computation is made using this library.

Parameters

search_language (str) – language to search

Returns

most similar language

Return type

str

static get_version() int

Get the latest version of the game.

Returns

latest version of the game

Return type

int

static get_queue(queue_id: int) async_riot_api.types.QueueDD

Get information about the given queue.

Parameters

queue_id (int) – queue ID

Returns

information about the queue

Return type

QueueDD

static get_champion_from_correct_name(name: str) Optional[async_riot_api.types.ShortChampionDD]

Get the short champion given its correct name. Useful instead of compute_champion_from_similar_name() if you already know the correct name.

Parameters

name (str) – correct name of the champion, case-sensitive

Returns

short information about the champion

Return type

Optional[ShortChampionDD]

static get_champion_from_id(champ_id: int) Optional[async_riot_api.types.ShortChampionDD]

Get the short champion given its ID. You can get a champ ID from many API calls.

Parameters

champ_id (int) – integer champion ID, same as ShortChampionDD.int_id

Returns

short champion

Return type

Optional[ShortChampionDD]

async static get_full_champion_from_correct_name(name: str, language: str = 'en') async_riot_api.types.ChampionDD

Get the complete information about a champion given its correct name, in any available language. If the passed language is not present in this list, compute_language() is called.

Parameters
  • name (str) – correct name of a champion, same as ShortChampionDD.id

  • language (str) – any available language. Default ‘en’

Returns

full information about a champion

Return type

ChampionDD

static get_map_icon_url(map_id: int) str

Returns the url to the image for the given map. Map ID can be found in MatchDto. Complete list of map IDs here.

IMPORTANT: no check will be made about data existence, meaning that passing a wrong map_id will simply result in a broken url. No error will be raised.

Parameters

map_id (int) – map ID

Returns

url to the given map image

Return type

str