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
- async get_account_by_puuid(puuid: str) async_riot_api.types.AccountDto
To get an account given its puuid.
- Parameters
puuid (str) – puuid of the account
- Returns
account data
- Return type
- 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.
- Parameters
- Returns
account data
- Return type
- async get_active_shards(game: str, puuid: str) async_riot_api.types.ActiveShardDto
No documentation found.
- Parameters
- Returns
shard data
- Return type
- async get_masteries(summoner_id: str) List[async_riot_api.types.ChampionMasteryDto]
Get the list of masteries for a summoner.
- 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.
- Parameters
- Returns
champion mastery for given summoner and champion
- Return type
- 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.
- async get_champion_rotation() async_riot_api.types.ChampionInfo
Get champion rotations, including free-to-play and low-level free-to-play rotations.
- Returns
information about champion rotations
- Return type
- 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.
- async get_clash_team_by_id(team_id: str) async_riot_api.types.ClashTeamDto
Get a clash team by its ID.
- async get_clash_tournaments() List[async_riot_api.types.TournamentDto]
Get all active or upcoming tournaments.
- 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.
- Parameters
team_id (str) –
- Returns
information about tournament
- Return type
- async get_clash_tournament_by_id(tournament_id: int) async_riot_api.types.TournamentDto
Get info about a clash tournament by its ID.
- Parameters
tournament_id (int) –
- Returns
information about the tournament
- Return type
- 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).- 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.
- Parameters
queue (str) – one among ‘RANKED_SOLO_5x5’, ‘RANKED_FLEX_SR’ or ‘RANKED_FLEX_TT’
- Returns
set of challengers
- Return type
- async get_league(summoner_id: str) Set[async_riot_api.types.LeagueEntryDTO]
Get the set of league entries for a given summoner.
- 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()
.- 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.
- async get_leagues(league_id: str) async_riot_api.types.LeagueListDTO
Get the list of summoners in the given league by its ID.
- Parameters
league_id (str) –
- Returns
list of summoners currently in the given league
- Return type
- async get_master_leagues(queue: str) async_riot_api.types.LeagueListDTO
Same as
get_challenger_leagues()
, but for masters.
- async get_platform_data_v3() async_riot_api.types.ShardStatus
DEPRECATED
Get information about LoL server status.- Returns
the current server status
- Return type
- async get_platform_data() async_riot_api.types.PlatformDataDto
Get information about LoL server status.
- Returns
the current LoL server status
- Return type
- 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()
.
- 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()
.- Parameters
match_id (str) –
- Returns
useful information about the given LoR match and its players
- Return type
- async get_lor_leaderboards() async_riot_api.types.LorLeaderboardDto
Get the list of players in Master tier.
- Returns
players in LoR Master tier
- Return type
- async get_lor_status() async_riot_api.types.PlatformDataDto
Get information about LoR servers status.
- Returns
the current LoR server status
- Return type
- 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.- 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()
.
- 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.
- Parameters
match_id (str) –
- Returns
more data about the match, ordered by time
- Return type
- 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 aRiotApiError
if the summoner is not in a game.- Parameters
summoner_id (str) –
- Returns
information about the current match and its players, if exists
- Return type
- async get_featured_games() async_riot_api.types.FeaturedGames
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.
- Returns
games that are currently being played
- Return type
- 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()
.- Parameters
account_id (str) –
- Returns
basic information about the summoner
- Return type
- 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.
- Parameters
summoner_name (str) – name of the summoner you are looking for
- Returns
basic information about the summoner
- Return type
- 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()
.- Parameters
puuid (str) –
- Returns
basic information about the summoner
- Return type
- 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()
.- Parameters
summoner_id (str) –
- Returns
basic information about the summoner
- Return type
- 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()
andget_match()
.
- 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
- 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
- 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.
- 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.
- 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
- static compute_language(search_language: str) str
Computes the most similar language available from this list. The similarity computation is made using this library.
- static get_version() int
Get the latest version of the game.
- Returns
latest version of the game
- Return type
- static get_queue(queue_id: int) async_riot_api.types.QueueDD
Get information about the given queue.
- 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
- Returns
full information about a champion
- Return type
- 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.