Skip to content

Added a few more calls #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions retroachievements/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,73 @@ def get_user_summary(self, user: str,
).json()
return result


def get_recent_achievements(self, user: str) -> dict:
"""
Get a user's most recent achievement within the last hour

Params:
u: Username to query
"""
result = self._call_api("API_GetUserRecentAchievements.php?", {"u": user}).json()
return result

def get_game_progress(self, user: str, game: int) -> dict:
"""
Get a users recent game info and progress

Params:
g: Game ID
u: Username to query
"""
result = self._call_api("API_GetGameInfoAndUserProgress.php?", {"g": game, "u": user}).json()
return result


def get_achievements_on_day(self, user: str, date: int) -> dict:
"""
Get a user's cheevos from a specific date

Params:
u: Username to query
d: Date to query
"""
result = self._call_api("API_GetAchievementsEarnedOnDay.php?", {"u": user, "d": date}).json()
return result

def get_achievements_range(self, user: str, f: int, t: int) -> dict:
"""
Get a user's cheevos from a specific date

Params:
u: Username to query
f: From date to query (must be in epoch timestamp format)
t: To date to query (must be in epoch timestamp format)
"""
result = self._call_api("API_GetAchievementsEarnedOnDay.php?", {"u": user, "f": f, "t": t }).json()
return result

def get_all_completion_progress(self, user: str) -> dict:
"""
Get a user's info and progress on all games

Params:
u: Username to query
"""
result = self._call_api("API_GetUserCompletionProgress.php?", {"u": user}).json()
return result

def get_awards_badges(self, user: str) -> list:
"""
Get a user's awards and badges on RA

Params:
u: Username to query
"""
result = self._call_api("API_GetUserAwards.php?", {"u": user}).json()
return result


# Game endpoints

def get_game(self, game: int) -> dict:
Expand Down