File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 2
2
import requests
3
3
4
4
def session (token ):
5
- global headers
5
+ global headers , url
6
+ url = 'https://api.rushstats.com/v1/'
6
7
headers = {'Authorization' : token }
7
8
8
9
def get_player (tag ):
9
- return requests . get ( 'https://api.rushstats.com/v1/ player/' + tag , headers = headers ). json ( )
10
+ return getdata ( ' player/', tag )
10
11
11
12
def get_team (tag ):
12
- return requests . get ( 'https://api.rushstats.com/v1/ team/' + tag , headers = headers ). json ( )
13
+ return getdata ( ' team/', tag )
13
14
14
15
def team_search (keyword ):
15
- return requests . get ( 'https://api.rushstats.com/v1/ search/team/' + keyword , headers = headers ). json ( )
16
+ return getdata ( ' search/team/', keyword )
16
17
17
18
def top_players (count ):
18
- return requests .get ('https://api.rushstats.com/v1/leaderboard/players?count=' + str (count ), headers = headers ).json ()
19
+ return getdata ('leaderboard/players?count=' , count )
20
+
21
+ def getdata (end , arg ):
22
+ if 'headers' in globals ():
23
+ return requests .get (url + end + str (arg ), headers = headers ).json ()
24
+ else :
25
+ print ('Please authenticate using your token!' )
You can’t perform that action at this time.
0 commit comments