-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
167 lines (114 loc) · 5.91 KB
/
api.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import champyongg.requests
from champyongg.common import ChampyonGGObject
from champyongg.classes.champion import Champion
from champyongg.classes.generaldata import GeneralData, Skills
from champyongg.classes.itemset import ItemSet
from champyongg.classes.matchup import Matchup
from champyongg.classes.runeset import RuneSet
from champyongg.classes.skillset import SkillSet
from champyongg.classes.summonerspellset import SummonerSpellSet
from .classes.stats import Stats
def set_api_key(key):
"""Set your API key
key str the key to use
"""
champyongg.requests.api_key = key
def print_calls(on):
"""Sets whether to print calls to stdout as they are made
on bool the region to query against
"""
champyongg.requests.print_calls = on
def get_champions():
"""return http://api.champion.gg/docs/#api-Champion-GetChampions"""
request = 'champion'
return {datum['key']: Champion(datum) for datum in champyongg.requests.get(request)}
def get_general_data(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionGeneralData
"""
request = 'champion/{name}/general'.format(name=champion)
return {datum['role']: GeneralData(datum) for datum in champyongg.requests.get(request)}
def get_matchups_by_role(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMatchups
"""
request = '/champion/{name}/matchup'.format(name=champion)
return {dictionary['role']: {datum['key']: Matchup(datum) for datum in dictionary['matchups']} for dictionary in champyongg.requests.get(request)}
def get_most_popular_items(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostPopularItems
"""
request = '/champion/{name}/items/finished/mostPopular'.format(name=champion)
return {datum['role']: ItemSet(datum) for datum in champyongg.requests.get(request)}
def get_most_popular_skills(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostPopularSkill
"""
request = '/champion/{name}/skills/mostPopular'.format(name=champion)
return {datum['role']: SkillSet(datum) for datum in champyongg.requests.get(request)}
def get_most_popular_starting_items(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostPopularStartingItems
"""
request = '/champion/{name}/items/starters/mostPopular'.format(name=champion)
return {datum['role']: ItemSet(datum) for datum in champyongg.requests.get(request)}
def get_most_popular_summoners(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostPopularSummoners
"""
request = '/champion/{name}/summoners/mostPopular'.format(name=champion)
return {datum['role']: SummonerSpellSet(datum) for datum in champyongg.requests.get(request)}
def get_most_popular_runes(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostPopularRunes
"""
request = '/champion/{name}/runes/mostPopular'.format(name=champion)
return {datum['role']: RuneSet(datum) for datum in champyongg.requests.get(request)}
def get_most_winning_items(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostWinningItems
"""
request = '/champion/{name}/items/finished/mostWins'.format(name=champion)
return {datum['role']: ItemSet(datum) for datum in champyongg.requests.get(request)}
def get_most_winning_starting_items(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostWinningStartingItems
"""
request = '/champion/{name}/items/starters/mostWins'.format(name=champion)
return {datum['role']: ItemSet(datum) for datum in champyongg.requests.get(request)}
def get_most_winning_summoners(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostWinningSummoners
"""
request = '/champion/{name}/summoners/mostWins'.format(name=champion)
return {datum['role']: SummonerSpellSet(datum) for datum in champyongg.requests.get(request)}
def get_most_winning_runes(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostWinningRunes
"""
request = '/champion/{name}/runes/mostWins'.format(name=champion)
return {datum['role']: RuneSet(datum) for datum in champyongg.requests.get(request)}
def get_most_winning_skills(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionMostWinningSkill
"""
request = '/champion/{name}/skills/mostWins'.format(name=champion)
return {datum['role']: SkillSet(datum) for datum in champyongg.requests.get(request)}
def get_skills(champion):
"""champion <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionSkills
"""
request = '/champion/{name}/skills'.format(name=champion)
return Skills(champyongg.requests.get(request))
#return {key: Skills(datum) for key, datum in champyongg.requests.get(request).items()}
def get_specific_matchup(champion, enemy):
"""champion <str> champion name
enemy <str> champion name
return http://api.champion.gg/docs/#api-Champion-GetChampionSpecificMatchup
"""
request = '/champion/{name}/matchup/{enemy}'.format(name=champion, enemy=enemy)
return {datum['role']: Matchup(datum) for datum in champyongg.requests.get(request)}
def get_stats():
"""return http://api.champion.gg/stats/overall"""
request = 'stats/overall'
return Stats(champyongg.requests.get(request))