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
65As 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
1513DEFAULT :
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
2617The 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.
0 commit comments