Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 54 additions & 37 deletions docs/v1/get-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,56 @@ A call to this endpoint returns comments of a specified kind: game, achievement,

::: code-group

```Kotlin [User]
val credentials = RetroCredentials("<username>", "<web api key>")
val api: RetroInterface = RetroClient(credentials).api
```ts [NodeJS]
import { buildAuthorization, getComments } from "@retroachievements/api";

val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnUserWall(
username = "MaxMilyin",
)
// First, build your authorization object.
const username = "<your username on RA>";
const webApiKey = "<your web API key>";

if (response is NetworkResponse.Success) {
// handle the data
val comments: GetComments.Response = response.body
const authorization = buildAuthorization({ username, webApiKey });

} else if (response is NetworkResponse.Error) {
// if the server returns an error it be found here
val errorResponse: ErrorResponse? = response.body
// Then, make the API call depending on what kind of comments you want.

// if the api (locally) had an internal error, it'll be found here
val internalError: Throwable? = response.error
}
```
// For comments on a user's wall, call the following:
const userWallComments = await getComments(authorization, {
identifier: "MaxMilyin",
});

```Kotlin [Game]
val credentials = RetroCredentials("<username>", "<web api key>")
val api: RetroInterface = RetroClient(credentials).api

val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnGameWall(
gameId = 14402,
)
// For comments on a game's wall, call the following:
const gameWallComments = await getComments(authorization, {
identifier: 14402,
kind: "game",
});

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
}
// For comments on an achievement's wall, call the following:
const achievementWallComments = await getComments(authorization, {
identifier: 14402,
kind: "achievement",
});
```

```Kotlin [Achievement]
```Kotlin
val credentials = RetroCredentials("<username>", "<web api key>")
val api: RetroInterface = RetroClient(credentials).api

val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnAchievementWall(
achievementId = 14402,
// get comments currently on user's wall
val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnUserWall(
username = "MaxMilyin",
)

// to get comments from a game's wall, use the following:
//
// val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnGameWall(
// gameId = 14402,
// )

// to get comments from an achievement's wall, use the following:
//
// val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnAchievementWall(
// achievementId = 14402,
// )

if (response is NetworkResponse.Success) {
// handle the data
val comments: GetComments.Response = response.body
Expand Down Expand Up @@ -112,11 +112,28 @@ 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

| 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 |