Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import requests
# Riot API documentation was used.
# https://developer.riotgames.com/api-methods/ and https://developer.riotgames.com/static-data.html
# I've seen a youtube video to write the first two functions. https://www.youtube.com/watch?v=ml0lKDU5JvY
APIKey = "RGAPI-4d94e2e2-0d78-47f6-8e52-5d5f0b31e444"
def requestSummonerData(region, summonerName, APIKey):
"""Returns Summoner Data such as name and summoner level by taking region, summoner name and api key as input"""
URL = "https://" + region + ".api.riotgames.com/lol/summoner/v3/summoners/by-name/" + summonerName + "?api_key=" + APIKey
# The lines below are used to obtain data from the API and store it in JSON format.
response = requests.get(URL)
return response.json()
def requestRankedData(region, summonerID, APIKey):
"""Returns Ranked Data such as league name and rank by taking region, summoner id and api key as input"""
URL = "https://" + region + ".api.riotgames.com/lol/league/v3/positions/by-summoner/" + summonerID + "?api_key=" + APIKey
response = requests.get(URL)
return response.json()
def requestMatchListData(region, accountID, APIKey):
"""Returns Match List such as champion and game Id by taking region, account id and api key as input"""
URL = "https://" + region + ".api.riotgames.com/lol/match/v3/matchlists/by-account/" + accountID + "?api_key=" + APIKey
response = requests.get(URL)
return response.json()
def requestMatchDetails(region, matchID, APIKey):
"""Returns Match Detais such as kills, deaths and assists by taking region, match id and api key as input"""
URL = "https://" + region + ".api.riotgames.com/lol/match/v3/matches/" + matchID + "?api_key=" + APIKey
response = requests.get(URL)
return response.json()
def requestGameLastVersion():
"""Returns Game Last Version so it can be used to keep data Champion Data updated. Takes no input"""
URL = "https://ddragon.leagueoflegends.com/api/versions.json"
response = requests.get(URL)
return response.json()
def requestChampionData():
"""Returns Champion Data such as champion name and lore. Takes no input"""
lastVersion = requestGameLastVersion()
URL = "http://ddragon.leagueoflegends.com/cdn/" + lastVersion[0] + "/data/en_US/champion.json"
response = requests.get(URL)
return response.json()