REST API

Embedded Web REST API

The login server has an embedded web server that servers an API on port 6000 unless otherwise specified in the config

login.json
{
"web_api": {
"enabled": true, // enable/disable embedded webserver api
"port": 6000 // the port you want the web api to serve on (recommended not to change)
},
}

You have the option to disable it, or change the port altogether

API Tokens

The login server requires API tokens to interact with the API, they can be generated via the CLI

Using the CLI Interface

[email protected]:~/server$ ./loginserver web-api-token:create --write --read

The token will persist to the login_api_tokens table

MariaDB [peq]> select * from login_api_tokens;
+----+--------------------------------------+-----------+----------+---------------------+---------------------+
| id | token | can_write | can_read | created_at | updated_at |
+----+--------------------------------------+-----------+----------+---------------------+---------------------+
| 1 | b1bb9eb7-416c-487a-bb91-aedc59e0c57d | 1 | 1 | 2019-09-17 04:23:30 | 2019-09-17 04:23:30 |
+----+--------------------------------------+-----------+----------+---------------------+---------------------+

To create read only users, simply specify only the --read flag when creating users

Note As a general rule, API calls that are GET are going to require --read while POST HTTP calls will require --write

API Endpoints

The login server has a small handful of endpoints which have been created, it is easy to add more as needed

PHP Client

There is an example of a PHP client that interacts with this API located here

Login Accounts

post
Login Account Create

http://loginserver:6000/v1/account/create
Request
Response
Request
Path Parameters
Authorization
required
string
Authorization: Bearer <token>
Response
200: OK
[
{
"local_ip" : "127.0.0.1",
"players_online" : 0,
"remote_ip" : "",
"server_list_id" : 3,
"server_long_name" : "Akkas Docker PEQ Installer (L)",
"server_short_name" : "Akkas Docker PEQ Installer (L)",
"server_status" : -2,
"zones_booted" : 0
}
]
Request Body
{
"username": "test",
"password": "test",
"email": "<optional>"
}

post
Validate Login Account Credentials

http://loginserver:6000/v1/account/credentials/validate/local
Request
Response
Request
Path Parameters
Authorization
required
string
Authorization: Bearer <token>
Response
200: OK
{
"data": {
"account_id": 3,
},
"message": "Credentials valid!"
}
Request Body
{
"username": "test",
"password": "test",
"email": "<optional>"
}

post
Update Login Account Credentials

http://loginserver:6000/v1/account/credentials/update/local
Request
Response
Request
Path Parameters
Authorization
required
string
Authorization: Bearer <token>
Response
200: OK
{
"message": "Loginserver account credentials updated!"
}
400: Bad Request
{
"error": "Failed to update loginserver account credentials!"
}
{
"username": "test",
"password": "newpassword"
}

World Servers

get
Get World Server List

http://loginserver:6000/v1/servers/list
Request
Response
Request
Path Parameters
Authorization
required
string
Authorization: Bearer <token>
Response
200: OK
[
{
"local_ip" : "127.0.0.1",
"players_online" : 0,
"remote_ip" : "",
"server_list_id" : 3,
"server_long_name" : "Akkas Docker PEQ Installer (L)",
"server_short_name" : "Akkas Docker PEQ Installer (L)",
"server_status" : -2,
"zones_booted" : 0
}
]