Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. import requests
  2. import json
  3. import time
  4.  
  5. def requestSummonerData(region, summonerName, APIKey):
  6. #URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v4/summoner/by-name/" + summonerName + "?api_key=" + APIKey
  7. APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
  8. region = "na1"
  9. summonerName = "Jamishio"
  10.  
  11. URL = "https://" + region + ".api.riotgames.com/lol/summoner/v4/summoners/by-name/" + summonerName + "?api_key=" + APIKey
  12.  
  13. print (URL)
  14. #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.
  15. response = requests.get(URL)
  16. #Here I return the JSON we just got.
  17. return response.json()
  18.  
  19. def matchList(accountId, APIKey):
  20.  
  21. URL = "https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/" + accountId + "?api_key=" + APIKey
  22. #APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
  23. response = requests.get(URL)
  24. return response.json()
  25.  
  26. def matchData(gameids, APIKey):
  27.  
  28. for gameid in gameids[:5]:
  29. URL = "https://na1.api.riotgames.com/lol/match/v4/matches/" + str(gameid) + "?api_key=" + APIKey
  30. #time.sleep(1)
  31. #print(URL)
  32.  
  33. response = requests.get(URL)
  34. return response.json()
  35.  
  36. def main():
  37. #region = (str)(input('Please enter a region: '))
  38. #summonerName = (str)(input('Please enter a summoner name: '))
  39. #APIKey = (str)(input('Please enter your API key: '))
  40.  
  41. APIKey = "RGAPI-bb2d9042-4ec2-4cc1-a212-3ba3e24a64ad"
  42. region = "na1"
  43. summonerName = "Jamishio"
  44. responseJSON = requestSummonerData(region, summonerName, APIKey)
  45. #print(responseJSON)
  46.  
  47. accountId = responseJSON["accountId"]
  48.  
  49. #print(accountId)
  50.  
  51. matches = matchList(accountId, APIKey)
  52. gameids = [item['gameId']for item in matches['matches']]
  53. #print(gameids)
  54. #print(matches['matches'][0]['gameId'])
  55. data = matchData(gameids, APIKey)
  56.  
  57. #print(data["gameId"])
  58. #firstBlood = [item["firstBloodKill"]for item in matches['data']]
  59.  
  60. #print(firstBlood)
  61. #print(data["participants"][0])
  62. print(data)
  63. #gameId = matches["gameId"]
  64. #games = gameId()
  65. #print(gameId)
  66.  
  67. if __name__ == "__main__":
  68. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement