diff --git a/matches.py b/matches.py new file mode 100644 index 0000000..d7f00b9 --- /dev/null +++ b/matches.py @@ -0,0 +1,23 @@ +import opendota + +match_client = opendota.MatchesApi() + +def serialize_player(player): + player_data = { + 'personaname': player.personaname, + 'kills': player.kills, + 'deaths': player.deaths, + 'assists': player.assists, + 'total_gold': player.total_gold, + 'last_hits': player.last_hits, + 'denies': player.denies, + } + return player_data + +def serialize_match(match_id): + match = match_client.get_matches_by_match_id(match_id) + match_data = { + 'players': [serialize_player(player) for player in match.players], + } + return match_data +