Skip to content

Commit bb42822

Browse files
committed
Add match-v5 example
1 parent 0e3273e commit bb42822

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎examples/match.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
from dotenv import load_dotenv
4+
5+
from pyke import Continent, Division, Pyke, Queue, Region, Tier
6+
7+
load_dotenv()
8+
API_KEY = os.getenv("RIOT_API_KEY")
9+
api = Pyke(API_KEY)
10+
11+
# Let's get some plat 2 players
12+
league = api.league.by_queue_tier_division(
13+
Region.EUW, Queue.SOLO_DUO, Tier.PLATINUM, Division.II
14+
)
15+
16+
champions: dict[str, int] = {}
17+
18+
for player in league[0:49]:
19+
# Now we get the players last two matches
20+
match_ids = api.match.match_ids_by_puuid(Continent.EUROPE, player.puuid, count=2)
21+
22+
# Fetch and analyze each match
23+
for match_id in match_ids:
24+
match = api.match.by_match_id(Continent.EUROPE, match_id)
25+
26+
# Count wins for top and mid champions
27+
for participant in match.info.participants:
28+
if participant.team_position == "TOP" or participant.team_position == "MID":
29+
if participant.champion_name not in champions:
30+
champions[participant.champion_name] = 1
31+
else:
32+
champions[participant.champion_name] += 1
33+
34+
# Print the final champion win count dictionary
35+
print(champions)

0 commit comments

Comments
 (0)