Skip to content

Commit be68935

Browse files
authored
docs: rewrite the AOTW endpoint documentation (#6)
1 parent 19d48ac commit be68935

File tree

9 files changed

+190
-2121
lines changed

9 files changed

+190
-2121
lines changed

docs/.vitepress/config.mts

+9-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ export default defineConfig({
4343
text: "Feed",
4444
collapsible: true,
4545
items: [
46-
{
47-
text: "Achievement of the Week",
48-
link: "/v1/feed/get-achievement-of-the-week",
49-
},
5046
{
5147
text: "Claims",
5248
link: "/v1/feed/get-claims",
@@ -169,6 +165,15 @@ export default defineConfig({
169165
},
170166
],
171167
},
168+
{
169+
text: "Events",
170+
items: [
171+
{
172+
text: "Achievement of the Week",
173+
link: "/v1/events/achievement-of-the-week",
174+
},
175+
],
176+
},
172177
{
173178
text: "Tickets",
174179
collapsible: true,

docs/components/SampleRequest.vue

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script setup>
2+
import { computed, defineProps } from "vue";
3+
4+
const props = defineProps({
5+
httpVerb: {
6+
type: String,
7+
required: true,
8+
validator: (value) =>
9+
["GET", "POST", "PUT", "PATCH", "DELETE"].includes(value),
10+
},
11+
});
12+
13+
const verbClass = computed(() => {
14+
switch (props.httpVerb) {
15+
case "GET":
16+
return "bg-green-600";
17+
case "POST":
18+
return "bg-blue-600";
19+
case "PUT":
20+
return "bg-purple-600";
21+
case "PATCH":
22+
return "bg-yellow-600";
23+
case "DELETE":
24+
return "bg-red-600";
25+
default:
26+
return "bg-neutral-600";
27+
}
28+
});
29+
</script>
30+
31+
<template>
32+
<div
33+
class="-mx-6 overflow-y-auto px-5 py-2 sm:mx-0 sm:px-4 my-1 bg-neutral-100 sm:rounded-lg dark:bg-neutral-950"
34+
>
35+
<div class="flex gap-x-4 sm:gap-x-2 items-center text-sm">
36+
<div
37+
:class="`${verbClass} text-white text-xs font-bold rounded-full px-2 py-0.5`"
38+
>
39+
{{ props.httpVerb }}
40+
</div>
41+
42+
<p class="font-semibold">
43+
<slot></slot>
44+
</p>
45+
</div>
46+
</div>
47+
</template>

docs/public/aotw.png

45.5 KB
Loading
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<script setup>
2+
import SampleRequest from '../../components/SampleRequest.vue';
3+
</script>
4+
5+
# Achievement of the Week
6+
7+
A call to this endpoint will retrieve comprehensive metadata about the current Achievement of the Week. The current achievement of the week can be found on the site's home page:
8+
9+
![AOTW](/aotw.png)
10+
11+
## HTTP Request
12+
13+
<SampleRequest httpVerb="GET">https://retroachievements.org/API/API_GetAchievementOfTheWeek.php</SampleRequest>
14+
15+
### Query Parameters
16+
17+
| Name | Description |
18+
| :--- | :---------------- |
19+
| `z` | Your username. |
20+
| `y` | Your web API key. |
21+
22+
## Client Library
23+
24+
::: code-group
25+
26+
```ts [NodeJS]
27+
import {
28+
buildAuthorization,
29+
getAchievementOfTheWeek,
30+
} from "@retroachievements/api";
31+
32+
// First, build your authorization object.
33+
const userName = "<your username on RA>";
34+
const webApiKey = "<your web API key>";
35+
36+
const authorization = buildAuthorization({ userName, webApiKey });
37+
38+
// Then, make the API call.
39+
const achievementOfTheWeek = await getAchievementOfTheWeek(authorization);
40+
```
41+
42+
:::
43+
44+
## Response
45+
46+
::: code-group
47+
48+
```json [HTTP Response]
49+
{
50+
"Achievement": {
51+
"ID": 178634,
52+
"Title": "Saved Summer",
53+
"Description": "Defeat the Flower and let Summer Get Busy",
54+
"Points": 10,
55+
"TrueRatio": 11,
56+
"Type": null,
57+
"Author": "StingX2",
58+
"DateCreated": "2021-10-16 23:53:32",
59+
"DateModified": "2021-10-17 19:26:09"
60+
},
61+
"Console": {
62+
"ID": 3,
63+
"Title": "SNES"
64+
},
65+
"ForumTopic": {
66+
"ID": 19685
67+
},
68+
"Game": {
69+
"ID": 2865,
70+
"Title": "~Hack~ Plumber For All Seasons, A"
71+
},
72+
"StartAt": "2023-10-23T00:00:00.000000Z",
73+
"TotalPlayers": 427,
74+
"Unlocks": [
75+
{
76+
"User": "Agnam",
77+
"RAPoints": 56120,
78+
"DateAwarded": "2023-10-26T22:13:34.000000Z",
79+
"HardcoreMode": 1
80+
}
81+
// ...
82+
],
83+
"UnlocksCount": 280,
84+
"UnlocksHardcoreCount": 268
85+
}
86+
```
87+
88+
```json [NodeJS]
89+
{
90+
"achievement": {
91+
"id": "165062",
92+
"title": "The True Hero",
93+
"description": "Receive any Ending as Han [Normal or Hard]",
94+
"points": "10",
95+
"trueRatio": "22",
96+
"author": "BigWeedSmokerMan",
97+
"dateCreated": "2021-08-08 17:47:46",
98+
"dateModified": "2021-08-09 12:20:05"
99+
},
100+
"console": { "id": "39", "title": "Saturn" },
101+
"forumTopic": { "id": "14767" },
102+
"game": { "id": "14513", "title": "Guardian Heroes" },
103+
"startAt": "2022-10-10 00:00:00",
104+
"totalPlayers": "219",
105+
"unlocks": [
106+
{
107+
"user": "Tirbaba2",
108+
"rAPoints": "72",
109+
"dateAwarded": "2022-10-10 01:42:19",
110+
"hardcoreMode": "1"
111+
}
112+
// ...
113+
],
114+
"unlocksCount": "40"
115+
}
116+
```
117+
118+
:::
119+
120+
## Source
121+
122+
| Repo | URL |
123+
| :----------------------- | :------------------------------------------------------------------------------------------------ |
124+
| RetroAchievements/RAWeb | https://github.com/RetroAchievements/RAWeb/blob/master/public/API/API_GetAchievementOfTheWeek.php |
125+
| RetroAchievements/api-js | https://github.com/RetroAchievements/api-js/blob/main/src/feed/getAchievementOfTheWeek.ts |

docs/v1/feed/get-achievement-of-the-week.md

-54
This file was deleted.

package-lock.json

+3-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
"author": "",
1919
"license": "ISC",
2020
"dependencies": {
21-
"vitepress": "^1.0.0-rc.32"
21+
"vitepress": "^1.0.0-rc.32",
22+
"vue": "^3.3.13"
2223
},
2324
"devDependencies": {
2425
"husky": "^8.0.3",
2526
"lint-staged": "^15.2.0",
26-
"prettier": "^3.1.1",
27-
"tailwindcss": "^3.4.0",
2827
"postcss-flexbugs-fixes": "^5.0.2",
29-
"postcss-preset-env": "^7.7.2"
28+
"postcss-preset-env": "^7.7.2",
29+
"prettier": "^3.1.1",
30+
"tailwindcss": "^3.4.0"
3031
},
3132
"lint-staged": {
3233
"*.{json,md,js,ts,tsx}": "prettier --write"

tailwind.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
darkMode: "class",
33
content: [
44
"./docs/**/*.{html,js,vue,ts,md,mdx}",
5+
"./docs/components/**/*.{html,js,vue,ts,md,mdx}",
56
"./docs/.vitepress/**/*.{html,js,vue,ts,md,mdx}",
67
],
78
};

0 commit comments

Comments
 (0)