@@ -27,56 +27,56 @@ A call to this endpoint returns comments of a specified kind: game, achievement,
2727
2828::: code-group
2929
30- ``` Kotlin [User]
31- val credentials = RetroCredentials (" <username>" , " <web api key>" )
32- val api: RetroInterface = RetroClient (credentials).api
30+ ``` ts [NodeJS]
31+ import { buildAuthorization , getComments } from " @retroachievements/api" ;
3332
34- val response : NetworkResponse < GetComments . Response , ErrorResponse > = api.getCommentsOnUserWall(
35- username = " MaxMilyin " ,
36- )
33+ // First, build your authorization object.
34+ const username = " <your username on RA> " ;
35+ const webApiKey = " <your web API key> " ;
3736
38- if (response is NetworkResponse .Success ) {
39- // handle the data
40- val comments: GetComments .Response = response.body
37+ const authorization = buildAuthorization ({ username , webApiKey });
4138
42- } else if (response is NetworkResponse .Error ) {
43- // if the server returns an error it be found here
44- val errorResponse: ErrorResponse ? = response.body
39+ // Then, make the API call depending on what kind of comments you want.
4540
46- // if the api (locally) had an internal error, it'll be found here
47- val internalError : Throwable ? = response.error
48- }
49- ```
41+ // For comments on a user's wall, call the following:
42+ const userWallComments = await getComments ( authorization , {
43+ identifier: " MaxMilyin " ,
44+ });
5045
51- ``` Kotlin [Game]
52- val credentials = RetroCredentials (" <username>" , " <web api key>" )
53- val api: RetroInterface = RetroClient (credentials).api
54-
55- val response: NetworkResponse <GetComments .Response , ErrorResponse > = api.getCommentsOnGameWall(
56- gameId = 14402 ,
57- )
46+ // For comments on a game's wall, call the following:
47+ const gameWallComments = await getComments (authorization , {
48+ identifier: 14402 ,
49+ kind: " game" ,
50+ });
5851
59- if (response is NetworkResponse .Success ) {
60- // handle the data
61- val comments: GetComments .Response = response.body
62-
63- } else if (response is NetworkResponse .Error ) {
64- // if the server returns an error it be found here
65- val errorResponse: ErrorResponse ? = response.body
66-
67- // if the api (locally) had an internal error, it'll be found here
68- val internalError: Throwable ? = response.error
69- }
52+ // For comments on an achievement's wall, call the following:
53+ const achievementWallComments = await getComments (authorization , {
54+ identifier: 14402 ,
55+ kind: " achievement" ,
56+ });
7057```
7158
72- ``` Kotlin [Achievement]
59+ ``` Kotlin
7360val credentials = RetroCredentials (" <username>" , " <web api key>" )
7461val api: RetroInterface = RetroClient (credentials).api
7562
76- val response: NetworkResponse <GetComments .Response , ErrorResponse > = api.getCommentsOnAchievementWall(
77- achievementId = 14402 ,
63+ // get comments currently on user's wall
64+ val response: NetworkResponse <GetComments .Response , ErrorResponse > = api.getCommentsOnUserWall(
65+ username = " MaxMilyin" ,
7866)
7967
68+ // to get comments from a game's wall, use the following:
69+ //
70+ // val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnGameWall(
71+ // gameId = 14402,
72+ // )
73+
74+ // to get comments from an achievement's wall, use the following:
75+ //
76+ // val response: NetworkResponse<GetComments.Response, ErrorResponse> = api.getCommentsOnAchievementWall(
77+ // achievementId = 14402,
78+ // )
79+
8080if (response is NetworkResponse .Success ) {
8181 // handle the data
8282 val comments: GetComments .Response = response.body
@@ -112,11 +112,28 @@ if (response is NetworkResponse.Success) {
112112]
113113```
114114
115+ ``` json [NodeJS]
116+ {
117+ "count" : 4 ,
118+ "total" : 4 ,
119+ "results" : [
120+ {
121+ "user" : " PlayTester" ,
122+ "ulid" : " 00003EMFWR7XB8SDPEHB3K56ZQ" ,
123+ "submitted" : " 2024-07-31T11:22:23.000000Z" ,
124+ "commentText" : " Comment 1"
125+ }
126+ // ...
127+ ]
128+ }
129+ ```
130+
115131:::
116132
117133## Source
118134
119135| Repo | URL |
120136| :--------- | :------------------------------------------------------------------------------------------------------------------- |
121137| RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetComments.php |
138+ | api-js | https://github.com/RetroAchievements/api-js/blob/main/src/comment/getComments.ts |
122139| api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |
0 commit comments