From 2f7fac1ec1ce761323b57db3af5e1adf26ee292c Mon Sep 17 00:00:00 2001 From: StiefelJackal Date: Thu, 15 Jan 2026 08:25:24 -0500 Subject: [PATCH 1/2] docs: condense Kotlin example --- docs/v1/get-comments.md | 55 ++++++++++------------------------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/docs/v1/get-comments.md b/docs/v1/get-comments.md index 74386a3..cfcf9b4 100644 --- a/docs/v1/get-comments.md +++ b/docs/v1/get-comments.md @@ -27,55 +27,26 @@ A call to this endpoint returns comments of a specified kind: game, achievement, ::: code-group -```Kotlin [User] +```Kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api +// get comments currently on user's wall val response: NetworkResponse = api.getCommentsOnUserWall( username = "MaxMilyin", ) -if (response is NetworkResponse.Success) { - // handle the data - val comments: GetComments.Response = response.body - -} else if (response is NetworkResponse.Error) { - // if the server returns an error it be found here - val errorResponse: ErrorResponse? = response.body - - // if the api (locally) had an internal error, it'll be found here - val internalError: Throwable? = response.error -} -``` - -```Kotlin [Game] -val credentials = RetroCredentials("", "") -val api: RetroInterface = RetroClient(credentials).api - -val response: NetworkResponse = api.getCommentsOnGameWall( - gameId = 14402, -) - -if (response is NetworkResponse.Success) { - // handle the data - val comments: GetComments.Response = response.body - -} else if (response is NetworkResponse.Error) { - // if the server returns an error it be found here - val errorResponse: ErrorResponse? = response.body - - // if the api (locally) had an internal error, it'll be found here - val internalError: Throwable? = response.error -} -``` - -```Kotlin [Achievement] -val credentials = RetroCredentials("", "") -val api: RetroInterface = RetroClient(credentials).api - -val response: NetworkResponse = api.getCommentsOnAchievementWall( - achievementId = 14402, -) +// to get comments from a game's wall, use the following: +// +// val response: NetworkResponse = api.getCommentsOnGameWall( +// gameId = 14402, +// ) + +// to get comments from an achievement's wall, use the following: +// +// val response: NetworkResponse = api.getCommentsOnAchievementWall( +// achievementId = 14402, +// ) if (response is NetworkResponse.Success) { // handle the data From beb2978ff030201131131953ccbbd7fa8c267e09 Mon Sep 17 00:00:00 2001 From: StiefelJackal Date: Thu, 15 Jan 2026 08:33:17 -0500 Subject: [PATCH 2/2] docs: add getComments JS function example --- docs/v1/get-comments.md | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/docs/v1/get-comments.md b/docs/v1/get-comments.md index cfcf9b4..3e03c0a 100644 --- a/docs/v1/get-comments.md +++ b/docs/v1/get-comments.md @@ -27,6 +27,35 @@ A call to this endpoint returns comments of a specified kind: game, achievement, ::: code-group +```ts [NodeJS] +import { buildAuthorization, getComments } from "@retroachievements/api"; + +// First, build your authorization object. +const username = ""; +const webApiKey = ""; + +const authorization = buildAuthorization({ username, webApiKey }); + +// Then, make the API call depending on what kind of comments you want. + +// For comments on a user's wall, call the following: +const userWallComments = await getComments(authorization, { + identifier: "MaxMilyin", +}); + +// For comments on a game's wall, call the following: +const gameWallComments = await getComments(authorization, { + identifier: 14402, + kind: "game", +}); + +// For comments on an achievement's wall, call the following: +const achievementWallComments = await getComments(authorization, { + identifier: 14402, + kind: "achievement", +}); +``` + ```Kotlin val credentials = RetroCredentials("", "") val api: RetroInterface = RetroClient(credentials).api @@ -83,6 +112,22 @@ if (response is NetworkResponse.Success) { ] ``` +```json [NodeJS] +[ + "count": 4, + "total": 4, + "results": [ + { + "user": "PlayTester", + "ulid": "00003EMFWR7XB8SDPEHB3K56ZQ", + "submitted": "2024-07-31T11:22:23.000000Z", + "commentText": "Comment 1" + }, + // ... + ] +] +``` + ::: ## Source @@ -90,4 +135,5 @@ if (response is NetworkResponse.Success) { | Repo | URL | | :--------- | :------------------------------------------------------------------------------------------------------------------- | | RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetComments.php | +| api-js | https://github.com/RetroAchievements/api-js/blob/main/src/comment/getComments.ts | | api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |