Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add UserWantToPlayList endpoint #52

Merged
merged 23 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions .husky/pre-commit
ioslife marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm lint-staged
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
pnpm lint-staged
Binary file added docs/public/want-to-play-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions docs/v1/get-user-want-to-play-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<script setup>
import SampleRequest from '../components/SampleRequest.vue';
</script>

# User Want to Play Lost
ioslife marked this conversation as resolved.
Show resolved Hide resolved

A call to this endpoint will retrieve a giver user's want to play list, targeted by their username.
ioslife marked this conversation as resolved.
Show resolved Hide resolved

[[toc]]

## On-site Representation

A user's want to play list can be found on on the user's Want to Play Games page:
ioslife marked this conversation as resolved.
Show resolved Hide resolved

![Want to Play](/want-to-play-list.png)
ioslife marked this conversation as resolved.
Show resolved Hide resolved

## HTTP Request

<SampleRequest httpVerb="GET">https://retroachievements.org/API/API_GetUserWantToPlayList.php?u=MaxMilyin</SampleRequest>

### Query Parameters

| Name | Required? | Description |
| :--- | :-------- | :----------------------------------------------------------- |
| `z` | Yes | Your username. |
| `y` | Yes | Your web API key. |
| `u` | Yes | The target username. |
| `c` | | Count, number of records to return (default: 100, max: 500). |
| `o` | | Offset, number of entries to skip (default: 0). |

## Client Library

::: code-group

```ts [NodeJS]
import {
buildAuthorization,
getUserWantToPlayList,
} from "@retroachievements/api";

// First, build your authorization object.
const username = "<your username on RA>";
const webApiKey = "<your web API key>";

const authorization = buildAuthorization({ username, webApiKey });

// Then, make the API call.
const userWantToPlayList = await getUserWantToPlayList(authorization, {
username: "MaxMilyin",
});
```

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

val response: NetworkResponse<GetUserWantToPlayList.Response, ErrorResponse> = api.getUserWantToPlayList(
username = "MaxMilyin",
)

if (response is NetworkResponse.Success) {
// handle the data
val completionProgress: GetUserWantToPlayList.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
}
```

:::
ioslife marked this conversation as resolved.
Show resolved Hide resolved
ioslife marked this conversation as resolved.
Show resolved Hide resolved

## Response

::: code-group

```json [HTTP Response]
{
"Count": 100,
"Total": 1287,
"Results": [
{
"GameID": 20246,
"Title": "~Hack~ Knuckles the Echidna in Sonic the Hedgehog",
"ImageIcon": "/Images/074560.png",
"ConsoleID": 1,
"TotalPoints": 1500,
"NumPossibleAchievements": 50
}
// ...
]
}
```

```json [NodeJS]
{
"count": 100,
"total": 1287,
"results": [
{
"gameId": 20246,
"title": "~Hack~ Knuckles the Echidna in Sonic the Hedgehog",
"imageIcon": "/Images/074560.png",
"consoleId": 1,
"totalPoints": 1500,
"numPossibleAchievements": 50
}
// ...
]
}
```

:::

## Source

| Repo | URL |
| :--------- | :------------------------------------------------------------------------------------------------------------------- |
| RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetUserWantToPlayList.php |
| api-js | https://github.com/RetroAchievements/api-js/blob/main/src/user/getUserWantToPlayList.ts |
| api-kotlin | https://github.com/RetroAchievements/api-kotlin/blob/main/src/main/kotlin/org/retroachivements/api/RetroInterface.kt |
ioslife marked this conversation as resolved.
Show resolved Hide resolved