-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.apib
135 lines (93 loc) · 4.03 KB
/
index.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
FORMAT: 1A
HOST: https://rwrstats.com/api
# Running With Rifles Stats REST API
Documentation about the [Running With Rifles Stats (RWRS)](https://rwrstats.com/) REST API. [About RWRS](https://rwrstats.com/about)
::: note
The RWRS REST API is provided "as is", without warranty of any kind, express or implied.
:::
::: warning
You are **required** to mention somewhere in your project - in a visible manner - that you're using the RWRS REST API.
Not doing so may lead to a ban from using the API.
:::
## Getting a Personal Access Token
Although this API is public, a Personal Access Token is **required** to prevent abuses. To obtain a Personal Access
Token:
1. Create an RWRS account by [signing in using your Steam account](https://rwrstats.com/sign-in)
2. Get your Personal Access Token by heading to [your settings page](https://rwrstats.com/settings#pat)
## Sending the Personal Access Token
All endpoints needs a valid Personal Access Token, otherwise a [403](https://httpstatuses.io/403) HTTP status code
will be returned. Send this HTTP header in all of your HTTP requests along your Personal Access Token:
```http
Authorization: Token {Your Personal Access Token}
```
## Base URL
The RWRS REST API base URL is `https://rwrstats.com/api`.
::: note
Using HTTPS is mandatory or you'll encounter redirections (which may not be appreciated by your HTTP client).
:::
## Rate limiting
To prevent abuse, all resources are rate-limited. Each IP address + Personal Access Token couple is limited to **1 request per
second**. Failing to respect this rate-limiting window will lead to a [429](https://httpstatuses.io/429) HTTP status
code.
## Ban
I reserve myself the right to ban from using the API anyone who might use it in an abusive fashion. In such cases,
all requests will return a [423](https://httpstatuses.io/423) HTTP status code.
## Cache
Some resources are subject to server-side caching (i.e you'll not necessarily get the most up-to-date data from the
server). Check their respective documentation for more information.
## HTTP status codes
The HTTP response status code must be used to check if the sent request was successfully handled or not:
- `2xx` Everything is OK. The response body will contain whatever the resource provide (check its doc)
- `4xx` Something is wrong on the client side (e.g an input parameter validation error)
- `5xx` There were a server error
::: note
The RWRS REST API doesn't provide internal error codes, but tries to make a meaningful use of HTTP status codes instead.
:::
## Input & output data format
Everything is [JSON](https://en.wikipedia.org/wiki/JSON) along a `Content-Type` HTTP header of `application/json`.
### Success (2xx)
The output can be different regarding the resource. Check their respective doc.
### Client error (4xx)
Typically an input parameters validation error:
```json
{
"message": {
"blow": "Missing required parameter in the JSON body",
"hey": "Missing required parameter in the JSON body"
}
}
```
In this case the `hey` and `blow` input parameters are missing.
If a query string parameter is missing or invalid, it's the same output:
```json
{
"message": {
"active": "Missing required parameter in the query string"
}
}
```
May also happen in other cases, e.g when the requested resource wasn't found:
```json
{
"message": "This thing does not exists."
}
```
### Server error (5xx)
They should not happen (exception for [503](https://httpstatuses.io/503)). If so, please [get in touch](https://rwrstats.com/feedback).
Example:
```json
{
"message": "Error creating this thing: IndexError: out of bounds"
}
```
## Data Structures
<!-- include(data_structures/common.apib) -->
<!-- include(data_structures/users.apib) -->
<!-- include(data_structures/players.apib) -->
<!-- include(data_structures/servers.apib) -->
<!-- include(data_structures/misc.apib) -->
<!-- include(resources/servers.apib) -->
<!-- include(resources/players.apib) -->
<!-- include(resources/friends.apib) -->
<!-- include(resources/users.apib) -->
<!-- include(resources/misc.apib) -->