Skip to content
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

feat(api): add API_GetUserAwards endpoint #1545

Merged

Conversation

wescopeland
Copy link
Member

This PR adds a new endpoint, API_GetUserAwards.php.

Why?

While it is currently possible to fetch a user's game completion stats with API_GetUserCompletedGames, this does not actually neatly map to what game awards a user has. For example, if a game has added new achievements in the months/years since the game was mastered by the user, it is not possible using the existing endpoint to know if a given user actually earned a mastery from the game.

This leads to awkward situations where a Discord bot might announce "User X just unlocked their 25th mastery!", when actually they got their 25th mastery years ago.

How?

GET https://retroachievements.org/API/API_GetUserAwards.php?z=...&y=...&u=SomeUser
{
  TotalAwardsCount: 14,
  HiddenAwardsCount: 9,
  MasteryAwardsCount: 9,
  CompletionAwardsCount: 1,
  EventAwardsCount: 0,
  SiteAwardsCount: 3,
  VisibleUserAwards: [
    {
      AwardedAt: '2014-09-29T12:41:48+00:00',
      AwardType: 'Mastery/Completion',
      AwardData: 504,
      AwardDataExtra: 0,
      DisplayOrder: 0,
      Title: 'Super Mario Land',
      ConsoleName: 'Game Boy',
      Flags: null,
      ImageIcon: '/Images/060955.png',
    },
    ...
  ],
};

Implementation Details

  • I have converted the existing mysqli stuff for fetching user site awards to use the new legacyDbFetch* functions.
  • I have written tests for the new endpoint.
  • Metadata for hidden awards is not exposed via this endpoint.

@Jamiras Jamiras merged commit 56f2bbf into RetroAchievements:master May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants