Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import time
- def requestSummonerData(region, summonerName, APIKey):
- #URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v4/summoner/by-name/" + summonerName + "?api_key=" + APIKey
- APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
- region = "na1"
- summonerName = "Jamishio"
- URL = "https://" + region + ".api.riotgames.com/lol/summoner/v4/summoners/by-name/" + summonerName + "?api_key=" + APIKey
- print (URL)
- #requests.get is a function given to us my our import "requests". It basically goes to the URL we made and gives us back a JSON.
- response = requests.get(URL)
- #Here I return the JSON we just got.
- return response.json()
- def matchList(accountId, APIKey):
- URL = "https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + APIKey
- #APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
- response = requests.get(URL)
- return response.json()
- def matchData(gameids, APIKey):
- for gameid in gameids[:5]:
- URL = "https://na1.api.riotgames.com/lol/match/v4/matches/" + str(gameid) + "?api_key=" + APIKey
- #time.sleep(1)
- #print(URL)
- response = requests.get(URL)
- return response.json()
- def main():
- #region = (str)(input('Please enter a region: '))
- #summonerName = (str)(input('Please enter a summoner name: '))
- #APIKey = (str)(input('Please enter your API key: '))
- APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
- region = "na1"
- summonerName = "Jamishio"
- responseJSON = requestSummonerData(region, summonerName, APIKey)
- #print(responseJSON)
- accountId = responseJSON["accountId"]
- #print(accountId)
- matches = matchList(accountId, APIKey)
- gameids = [item['gameId']for item in matches['matches']]
- #print(gameids)
- #print(matches['matches'][0]['gameId'])
- data = matchData(gameids, APIKey)
- #print(data["gameId"])
- #firstBlood = [item["firstBloodKill"]for item in matches['data']]
- #print(firstBlood)
- #print(data["participants"][0])
- print(data)
- #gameId = matches["gameId"]
- #games = gameId()
- #print(gameId)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement