@@ -10,7 +10,7 @@ A call to this endpoint will retrieve a given game's list of leaderboards, targe
1010
1111## On-site Representation
1212
13- A games 's list of leaderboards can be found on on the game's page:
13+ A game 's list of leaderboards can be found on the game's page:
1414
1515![ Game Leaderboards] ( /game-leaderboards.png )
1616
@@ -31,6 +31,24 @@ A games's list of leaderboards can be found on on the game's page:
3131
3232::: code-group
3333
34+ ``` ts [NodeJS]
35+ import {
36+ buildAuthorization ,
37+ getGameLeaderboards ,
38+ } from " @retroachievements/api" ;
39+
40+ // First, build your authorization object.
41+ const username = " <your username on RA>" ;
42+ const webApiKey = " <your web API key>" ;
43+
44+ const authorization = buildAuthorization ({ username , webApiKey });
45+
46+ // Then, make the API call.
47+ const gameLeaderboards = await getGameLeaderboards (authorization , {
48+ gameId: 14402 ,
49+ });
50+ ```
51+
3452``` Kotlin
3553val credentials = RetroCredentials (" <username>" , " <web api key>" )
3654val api: RetroInterface = RetroClient (credentials).api
@@ -83,11 +101,38 @@ if (response is NetworkResponse.Success) {
83101}
84102```
85103
104+ ``` json [NodeJS]
105+ {
106+ "count" : 29 ,
107+ "total" : 29 ,
108+ "results" : [
109+ {
110+ "id" : 104370 ,
111+ "rankAsc" : false ,
112+ "title" : " South Island Conqueror" ,
113+ "description" : " Complete the game with the highest score possible" ,
114+ "format" : " VALUE" ,
115+ "author" : " Scott" ,
116+ "authorUlid" : " 00003EMFWR7XB8SDPEHB3K56ZA" ,
117+ "state" : " active" ,
118+ "topEntry" : {
119+ "user" : " vani11a" ,
120+ "ulid" : " 00003EMFWR7XB8SDPEHB3K56ZQ" ,
121+ "score" : 390490 ,
122+ "formattedScore" : " 390,490"
123+ }
124+ }
125+ // ...
126+ ]
127+ }
128+ ```
129+
86130:::
87131
88132## Source
89133
90134| Repo | URL |
91135| :--------- | :------------------------------------------------------------------------------------------------------------------- |
92136| RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetGameLeaderboards.php |
137+ | api-js | https://github.com/RetroAchievements/api-js/blob/main/src/leaderboard/getGameLeaderboards.ts |
93138| api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |
0 commit comments