-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathval api python
63 lines (49 loc) · 2.24 KB
/
val api python
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
from riotwatcher import LolWatcher, ApiError
lol_watcher = LolWatcher('RGAPI-262172ac-c2c4-43cc-9f4c-83cc8e0e0ee2')
my_region = 'na1'
me = lol_watcher.summoner.by_name(my_region, 'Burninatooor')
print(me)
# all objects are returned (by default) as a dict
# lets see if i got diamond yet (i probably didnt)
my_ranked_stats = lol_watcher.league.by_summoner(my_region, me['id'])
print(my_ranked_stats)
# First we get the latest version of the game from data dragon
versions = lol_watcher.data_dragon.versions_for_region(my_region)
champions_version = versions['n']['champion']
# Lets get some champions
current_champ_list = lol_watcher.data_dragon.champions(champions_version)
print(current_champ_list)
# For Riot's API, the 404 status code indicates that the requested data wasn't found and
# should be expected to occur in normal operation, as in the case of a an
# invalid summoner name, match ID, etc.
#
# The 429 status code indicates that the user has sent too many requests
# in a given amount of time ("rate limiting").
try:
response = lol_watcher.summoner.by_name(my_region, 'this_is_probably_not_anyones_summoner_name')
except ApiError as err:
if err.response.status_code == 429:
print('We should retry in {} seconds.'.format(err.response.headers['Retry-After']))
print('this retry-after is handled by default by the RiotWatcher library')
print('future requests wait until the retry-after time passes')
elif err.response.status_code == 404:
print('Summoner with that ridiculous name not found.')
else:
raise
try:
# Get the player's Riot ID (username#tagline)
player_info = valorant_watcher.get_player(region, player_name, tagline)
# Get the player's recent matches (games)
recent_matches = valorant_watcher.get_recent_matches(region, player_info["puuid"])
# Print the recent matches
for match in recent_matches:
print("Match ID:", match["MatchID"])
print("Map:", match["Map"])
print("Date:", match["MatchStartTime"])
print("Kills:", match["Kills"])
print("Deaths:", match["Deaths"])
print("Assists:", match["Assists"])
print("Result:", match["WinStatus"])
print()
except Exception as e:
print("An error occurred:", e)