From dd6f6efd86d64aa2302535518f82e5c60e743419 Mon Sep 17 00:00:00 2001 From: StiefelJackal Date: Wed, 14 Jan 2026 12:49:02 -0500 Subject: [PATCH] docs: add getGameLeaderboards JS function example --- docs/v1/get-game-leaderboards.md | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/v1/get-game-leaderboards.md b/docs/v1/get-game-leaderboards.md index 1abf6c8..3b823ed 100644 --- a/docs/v1/get-game-leaderboards.md +++ b/docs/v1/get-game-leaderboards.md @@ -31,6 +31,24 @@ A games's list of leaderboards can be found on on the game's page: ::: code-group +```ts [NodeJS] +import { + buildAuthorization, + getGameLeaderboards, +} 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 getGameLeaderboards(authorization, { + gameId: 14402, +}); +``` + ```Kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api @@ -83,6 +101,32 @@ if (response is NetworkResponse.Success) { } ``` +```json [NodeJS] +{ + "count": 29, + "total": 29, + "results": [ + { + "id": 104370, + "rankAsc": false, + "title": " South Island Conqueror", + "description": "Complete the game with the highest score possible", + "format": "VALUE", + "author": "Scott", + "authorUlid": "00003EMFWR7XB8SDPEHB3K56ZA", + "state": "active", + "topEntry": { + "user": "vani11a", + "ulid": "00003EMFWR7XB8SDPEHB3K56ZQ", + "score": 390490, + "formattedScore": "390,490" + } + } + // ... + ] +} +``` + ::: ## Source @@ -90,4 +134,5 @@ if (response is NetworkResponse.Success) { | Repo | URL | | :--------- | :------------------------------------------------------------------------------------------------------------------- | | RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetGameLeaderboards.php | +| api-js | https://github.com/RetroAchievements/api-js/blob/main/src/leaderboard/getGameLeaderboards.ts | | api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |