Skip to content

Commit efcc565

Browse files
committed
Added readme for webservice, changed readme of RestAPI
1 parent 299d6d9 commit efcc565

File tree

2 files changed

+45
-34
lines changed

2 files changed

+45
-34
lines changed

plugins/restapi/README.md

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Plugin RestAPI
2-
This API provides a very simple RestAPI that you can call from your webserver to receive data from DCSServerBot.
3-
It is WIP, and it will be enhanced in the future.
2+
This API provides a very simple RestAPI that you can user together with the [WebService](../../services/webservice/README.md).
43

54
## Configuration
65
As RestAPI is an optional plugin, you need to activate it in main.yaml first like so:
@@ -9,44 +8,32 @@ opt_plugins:
98
- restapi
109
```
1110
12-
There is some very basic endpoint configuration available as of now, which you can add in your
13-
config/plugins/restapi.yaml like so:
11+
All you can set in your config/plugins/restapi.yaml for now is a prefix that should be added to the API endpoints:
1412
```yaml
1513
DEFAULT:
16-
listen: 0.0.0.0 # the interface to bind the internal webserver to
17-
port: 9876 # the port the internal webserver is listening on
1814
prefix: /stats # use this prefix (optional)
19-
debug: false # Enable /openapi.json, /docs and /redoc endpoints to test the API (default: false)
2015
```
21-
22-
> [!WARNING]
23-
> Do NOT enable debug for normal operations, especially, if you expose the REST service to the outside world.
24-
2516
## RestAPI
2617
The following commands are available through the API
2718
28-
| API | GET / POST | Parameters | Return | Description |
29-
|-------------------|------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
30-
| /getuser | POST | nick: string | {"name": string, "date": date} | Return a list of players ordered by last seen that match this nick. |
31-
| /servers | GET | | [{"name": string, "status": string, "address": string, "password": string, "mission": {"name": string, "uptime": string, "date_time": string, "theatre", string, "blue_slots: int, "red_slots": int, "blue_slots_used": int, "red_slots_used": int, "restart_time": int}}] | Status for each server. |
32-
| /stats | POST | nick: string, date: date | {<br>"deaths": int,<br>"aakills": int,<br>"aakdr": float,<br>"lastSessionKills": int,<br>"lastSessionDeaths": int,<br>"killsbymodule": [<br>{"module": string, "kills": int}<br>],<br>"kdrByModule": [<br>{"module": string, "kdr": float}<br>]<br>} | Statistics of this player |
33-
| /highscore | GET | [server_name: string], [period: string], [limit: int] | | Highscore output |
34-
| /topkills | GET | [limit: int] | {"fullNickname": string, "AAkills": int, "deaths": int, "AAKDR": float} | Top x of players ordered by kills descending. |
35-
| /topkdr | GET | [limit: int] | {"fullNickname": string, "AAkills": int, "deaths": int, "AAKDR": float} | Same as /topkills but ordered by AAKDR descending. |
36-
| /trueskill | GET | [limit: int] | | Top x trueskill ratings. |
37-
| /missilepk | POST | nick: string, date: date | {"weapon": {"weapon-name": string, "pk": float}} | Probability of kill for each weapon per given user. |
38-
| /credits | POST | nick: string, date: date | [{"id": int, "name": string, "credits": float}] | Credits of a specific player. |
39-
| /traps | POST | nick: string, date: string, [limit: int] | | Lists the traps of that user. |
40-
| /squadrons | GET | | [{"name": string, "description": string, "image_url": string, "locked": boolean, "role": string}] | Lists all squadrons. |
41-
| /squadron_members | POST | name: string | [{"name": string, "date": date}] | Lists the members of the squadron with that name. |
42-
| /linkme | POST | discord_id: string, force: bool | {"token": 1234, "timestamp": "2025-02-03 xx:xx:xx...", "rc": 0} | Same as /linkme in discord. Returns a new token that can be used in the in-game chat. |
19+
| API | GET / POST | Parameters | Description |
20+
|-------------------|------------|-------------------------------------------------------|---------------------------------------------------------------------------------------|
21+
| /serverstats | GET | | A comprehensive statistic for your whole setup. |
22+
| /servers | GET | | Status for each server. |
23+
| /getuser | POST | nick: string | Return a list of players ordered by last seen that match this nick. |
24+
| /stats | POST | nick: string, date: date | Statistics of this player |
25+
| /highscore | GET | [server_name: string], [period: string], [limit: int] | Highscore output |
26+
| /topkills | GET | [limit: int] | Top x of players ordered by kills descending. |
27+
| /topkdr | GET | [limit: int] | Same as /topkills but ordered by AAKDR descending. |
28+
| /trueskill | GET | [limit: int] | Top x trueskill ratings. |
29+
| /weaponpk | POST | nick: string, date: date | Probability of kill for each weapon per given user. |
30+
| /credits | POST | nick: string, date: date, [campaign] | Credits of a specific player. |
31+
| /traps | POST | nick: string, date: string, [limit: int] | Lists the traps of that user. |
32+
| /squadrons | GET | | Lists all squadrons. |
33+
| /squadron_members | POST | name: string | Lists the members of the squadron with that name. |
34+
| /squadron_credits | POST | name: string, [campaign] | Lists the members of the squadron with that name. |
35+
| /linkme | POST | discord_id: string, force: bool | Same as /linkme in discord. Returns a new token that can be used in the in-game chat. |
4336
4437
> [!NOTE]
45-
> To access the API documentation, you can enable debug and access the documentation with these links:
46-
> http://localhost:9876/docs
47-
> http://localhost:9876/redoc
48-
> Please refer to the [OpenAPI specification](https://swagger.io/specification/) for more information and the
49-
> warning about debug above.
50-
51-
> [!IMPORTANT]
52-
> It is advisable to use a reverse proxy like nginx and maybe SSL encryption between your webserver and this endpoint.
38+
> To get a more detailled API-documentation, please enable debug in your WebService config and
39+
> access https://localhost:9876/docs.

services/webservice/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Service WebService
2+
This service provides a simple web service. It is WIP, and it will be enhanced in the future.
3+
Currently you can use it with the [RestAPI plugin](https://github.com/frankkopp/DCSServerBot3/tree/master/services/restapi).
4+
5+
## Configuration
6+
The webservice can be configured in its config/services/webservice.yaml file:
7+
```yaml
8+
DEFAULT:
9+
listen: 0.0.0.0 # the interface to bind the internal webserver to
10+
port: 9876 # the port the webservice is listening on
11+
debug: false # Enable /openapi.json, /docs and /redoc endpoints to test the API (default: false)
12+
```
13+
14+
> [!NOTE]
15+
> To access the API documentation, you can enable debug and access the documentation with these links:
16+
> http://localhost:9876/docs
17+
> http://localhost:9876/redoc
18+
> Please refer to the [OpenAPI specification](https://swagger.io/specification/) for more information.
19+
20+
> [!WARNING]
21+
> Do NOT enable debug for normal operations, especially if you expose the port to the outside world.
22+
23+
> [!IMPORTANT]
24+
> It is advisable to use a reverse proxy like nginx and maybe SSL encryption to secure the webservice.

0 commit comments

Comments
 (0)