From c3b25a1cdad419a9628c764d9182e2adc50e98b1 Mon Sep 17 00:00:00 2001 From: Joshua Raphael Date: Mon, 16 Jun 2025 18:49:53 -0700 Subject: [PATCH] fix: update get-user-game-leaderboards to include js client call --- docs/v1/get-user-game-leaderboards.md | 58 ++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/docs/v1/get-user-game-leaderboards.md b/docs/v1/get-user-game-leaderboards.md index 0bb04fa..0b28418 100644 --- a/docs/v1/get-user-game-leaderboards.md +++ b/docs/v1/get-user-game-leaderboards.md @@ -34,7 +34,27 @@ You must query the user by either their username or their ULID. Please note the ## Client Library -Not yet supported. +::: code-group + +```ts [NodeJS] +import { + buildAuthorization, + getUserGameLeaderboards, +} from "@retroachievements/api"; + +// First, build your authorization object. +const username = ""; +const webApiKey = ""; + +const authorization = buildAuthorization({ username, webApiKey }); + +// Then, make the API call. +const gameLeaderboards = await getUserGameLeaderboards(authorization, { + gameId: 14402, +}); +``` + +::: ## Response @@ -59,8 +79,33 @@ Not yet supported. "Rank": 2, "DateUpdated": "2024-12-12T16:40:59+00:00" } - }, - ... + } + // ... + ] +} +``` + +```json [NodeJS] +{ + "count": 10, + "total": 64, + "results": [ + { + "id": 19062, + "rankAsc": true, + "title": "New Zealand One", + "description": "Complete New Zealand S1 in least time", + "format": "MILLISECS", + "userEntry": { + "user": "zuliman92", + "ulid": "00003EMFWR7XB8SDPEHB3K56ZQ", + "score": 12620, + "formattedScore": "2:06.20", + "rank": 2, + "dateUpdated": "2024-12-12T16:40:59+00:00" + } + } + // ... ] } ``` @@ -69,6 +114,7 @@ Not yet supported. ## Source -| Repo | URL | -| :---- | :------------------------------------------------------------------------------------------------ | -| RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetUserGameLeaderboards.php | +| Repo | URL | +| :----- | :------------------------------------------------------------------------------------------------ | +| RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetUserGameLeaderboards.php | +| api-js | https://github.com/RetroAchievements/api-js/blob/main/src/leaderboard/getUserGameLeaderboards.ts |