-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi_calls.py
More file actions
43 lines (32 loc) · 1.44 KB
/
Copy pathapi_calls.py
File metadata and controls
43 lines (32 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import api_constants, api_key
import requests
api_key = api_key.key
args = {'api_key': api_key}
def get_region(region):
return api_constants.REGIONS[region]
def summoner_lookup(summoner_name, region):
region = get_region(region)
asset = api_constants.ASSETS['summoner_lookup'].format(version=3, summonerName=summoner_name)
url = api_constants.URL['base'].format(region=region, asset=asset)
result = requests.get(url, params=args).json()
return result
def champion_mastery(summoner_id, num_champs, region):
region = get_region(region)
asset = api_constants.ASSETS['champion_mastery'].format(version=3, summonerId=summoner_id)
url = api_constants.URL['base'].format(region=region, asset=asset)
result = requests.get(url, params=args).json()
return result[:num_champs]
def match_history(account_id, champ_list, region):
region = get_region(region)
args['champion'] = champ_list
asset = api_constants.ASSETS['match_history'].format(version=3, accountId=account_id)
url = api_constants.URL['base'].format(region=region, asset=asset)
result = requests.get(url, params=args).json()
return result
def champion_lookup(region):
region = get_region(region)
args['dataById'] = 'true'
asset = api_constants.ASSETS['champion_lookup'].format(version=3)
url = api_constants.URL['base'].format(region=region, asset=asset)
result = requests.get(url, params=args).json()
return result['data']