Proofread 1.

This commit is contained in:
zkldi
2021-09-03 13:20:57 +01:00
parent 47b56ecb21
commit c690e2d908
25 changed files with 144 additions and 59 deletions
+7 -4
View File
@@ -9,6 +9,8 @@ This page covers how to present your permissions to the server, and what those p
There are two ways to authorise a request. The first one involves API keys.
### Token Authentication
To use authentication with a request, you should set a HTTP header of:
```
@@ -17,8 +19,9 @@ Authorization: Bearer API_KEY
Where API_KEY is the api key you wish to use.
The other way to authorise a request is with your session cookie. This is **NOT** recommended
for non-user use, and is instead a way for logged-in users to interact with the API as themselves.
### Self-Key Authentication
The other way to authorise a request is with your session cookie. This **MUST NOT** be used by code, and is instead a way for logged-in users to interact with the API as themselves.
To use authentication in this way, simply make a request with your `ktchi_production_session` or
`btchi_production_session` cookie.
@@ -27,11 +30,11 @@ The reason for this second authentication method is so that, when a user logs in
the cookie they were set to also interact with the API.
This type of authentication is referred to as "Self-Key" or "Session-Key" authentication, and it grants special
permissions, such as being able to change your password.
permissions over API Tokens, such as being able to change your password.
## Getting Tokens
Users may create API tokens at Settings > API Tokens. They may also revoke these tokens.
[Our OAuth2 Flow](../codebase/infrastructure/oauth2.md) should be used to acquire API Tokens.
## Permissions
+8 -8
View File
@@ -26,10 +26,10 @@ cool things, and used responsibly.
Abuse of this API will result in your ability to use it being banned.
The API has a rate limit of 100 requests every minute. This is a rather
generous rate limit, and you should not be close to hitting it.
The API has a rate limit of 500 requests every minute. This is a very
generous rate limit, and you should not even be close to hitting it.
If you are in a scenario where you might be hitting 100 requests a minute,
If you are in a scenario where you might be hitting even 100 requests a minute consistently,
please contact me at `zkldi#2965`. Otherwise, you might have your tokens revoked
for API abuse.
@@ -67,9 +67,9 @@ As the name implies, the Success Response is returned on a successful request.
| Property | Type | Description |
| :: | :: | :: |
| success | true | Always true for a successful response. |
| description | string | Information about what happened with the request. |
| body | Endpoint Dependent | Any data that the endpoint needs to return, such as a user's document from a profile request. |
| `success` | true | Always true for a successful response. |
| `description` | string | Information about what happened with the request. |
| `body` | Endpoint Dependent | Any data that the endpoint needs to return, such as a user's document from a profile request. |
The HTTP Status Code for any Success Response will always be of 2XX form.
@@ -79,8 +79,8 @@ As the name implies, the Failed Response is returned when a request fails.
| Property | Type | Description |
| :: | :: | :: |
| success | false | Always false for a failed response. |
| description | string | Information about what went wrong with the request. |
| `success` | false | Always false for a failed response. |
| `description` | string | Information about what went wrong with the request. |
The HTTP Status Code for any Failed Response will always be of either 4XX or 5XX form.
+5 -5
View File
@@ -23,19 +23,19 @@ Logs a user in and returns a session cookie.
| Property | Type | Description |
| :: | :: | :: |
| username | string | The user's username. This is compared case-insensitively.
| password | string | The user's password. |
| captcha | string | |
| `username` | string | The user's username. This is compared case-insensitively.
| `password` | string | The user's password. |
| `captcha` | string | |
### Response
| Property | Type | Description |
| :: | :: | :: |
| userID | integer | The ID of the user you authenticated as. |
| `userID` | integer | The ID of the user you authenticated as. |
| HTTP Header | Description |
| :: | :: |
| Set-Cookie | Contains a session cookie for future authentication. |
| `Set-Cookie` | Contains a session cookie for future authentication. |
### Example
+1 -1
View File
@@ -14,7 +14,7 @@ This endpoint greets the user.
*If permissions are required, they will be listed here.*
- example:permission
- example_permission
### Parameters
+1 -1
View File
@@ -12,7 +12,7 @@ Perform a score import that depends on a file, such as a .csv import.
### Permissions
- `submit:score`
- `submit_score`
### Parameters
+2 -2
View File
@@ -37,7 +37,7 @@ It's a good way of sanity checking whether your code works.
{
"serverTime": 1623331110661,
"version": "v2.0.0 (Mysterons)",
"permissions": ["score:submit", "example:permission"],
"permissions": ["score_submit", "example_permission"],
"echo": "helloworld"
}
```
@@ -68,7 +68,7 @@ POST /status
{
"serverTime": 1623331110662,
"version": "v2.0.0 (Mysterons)",
"permissions": ["score:submit", "example:permission"],
"permissions": ["score_submit", "example_permission"],
"echo": "hello world"
}
```
+3 -3
View File
@@ -108,7 +108,7 @@ PATCH /api/v1/users/1/games/iidx/SP/showcase
| Property | Type | Description |
| :: | :: | :: |
| `mode` | "folder" \| "chart" | Whether the stat to evaluate is on a folder or a chart. |
| `prop` | "grade" \| "lamp" \| "score" \| "percent" or "playcount" if mode is chart. | What property to evaluate on the given criteria. |
| `property` | "grade" \| "lamp" \| "score" \| "percent" or "playcount" if mode is chart. | What property to evaluate on the given criteria. |
| `chartID` | string, if mode === "chart" | If mode is chart, this should contain the relevant chartID. |
| `folderID` | string, if mode === "folder" | If mode is folder, this should contain the relevant folderID. |
| `gte` | number, if mode === "folder" | If mode is folder, this must contain the value the property must be greater than, i.e. lamp >= 6, or percent >= 90 |
@@ -125,7 +125,7 @@ PATCH /api/v1/users/1/games/iidx/SP/showcase
#### Request
```
GET /api/v1/users/1/games/iidx/SP/showcase/custom?mode=chart&prop=percent&chartID=some_chart_id
GET /api/v1/users/1/games/iidx/SP/showcase/custom?mode=chart&property=percent&chartID=some_chart_id
```
#### Response
@@ -133,7 +133,7 @@ GET /api/v1/users/1/games/iidx/SP/showcase/custom?mode=chart&prop=percent&chartI
{
stat: {
mode: "chart",
prop: "percent",
property: "percent",
chartID: "some_chart_id",
},
result: {
+4 -2
View File
@@ -2,6 +2,8 @@
This endpoints are for specific users information on specific game + playtype combinations.
This scenario appears frequently, and is typically shortened to UGPT.
*****
## Get information about a user's plays on a game + playtype.
@@ -311,7 +313,7 @@ GET /api/v1/users/zkldi/games/iidx/SP/pbs/best?alg=BPI
| :: | :: | :: |
| `pb` | PBDocument | The user's PB for this chart. |
| `chart` | ChartDocument | The chart this PB is on. |
| `scores` (Conditional) | ScoreDocument[] | If `getComposition` is present, then this field contains the array of score documents that composed this PB. |
| `scores` (Conditional) | Array<ScoreDocument> | If `getComposition` is present, then this field contains the array of score documents that composed this PB. |
### Example
@@ -863,7 +865,7 @@ GET /api/v1/users/1/games/iidx/SP/settings
| Property | Type | Description |
| :: | :: | :: |
| `<body>` | UGPTSettingsDocument | The new UGPTSettingsDocument |
| `<body>` | UGPTSettingsDocument | The new UGPTSettingsDocument. |
### Example
+20 -1
View File
@@ -109,7 +109,10 @@ None.
| Property | Type | Description |
| :: | :: | :: |
| `<body>` | Array&lt;UserGameStatsDocument&gt; | The array of User Game Stats this user has. |
| `<body>` | Array&lt;UserGameStatsDocument & __rankingData&gt; | The array of User Game Stats this user has. |
!!! info
For UI reasons, the UserGameStatsDocuments here have an additional `__rankingData` property, which contains leaderboard ranking information for this user.
### Example
@@ -133,6 +136,16 @@ GET /api/v1/users/1/game-stats
classes: {
dan: 14
},
__rankingData: {
ktRating: {
ranking: 15,
outOf: 74
},
BPI: {
ranking: 12,
outOf: 74
}
}
}, {
userID: 1,
game: "gitadora",
@@ -142,6 +155,12 @@ GET /api/v1/users/1/game-stats
},
classes: {
skillColour: 1
},
__rankingData: {
skill: {
ranking: 199,
outOf: 202
}
}
}]
```