Skip to content

REST API

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

The API is very basic in its current form but serves very simple use cases.

Warning

For security reasons, its recommended that this port is exposed behind a secure HTTP proxy as the API surface itself is not encrypted and credentials are sent over the wire. Use responsibily.

{
  "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

eqemu@dc25a75287d7:~/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 |
+----+--------------------------------------+-----------+----------+---------------------+---------------------+

Warning

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

Info

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

https://github.com/Akkadius/eqemu-loginserver-php-api-client

Accounts

Example

BaseURL http://loginserver:6000

Header Authorization: Bearer <token>

Create local loginserver account

Request Body

{
    "username": "test",
    "password": "test",
    "email": "<optional>"
}

Responses

{
    "data": {
        "account_id": 1,
    },
    "message": "Account created successfully!"
}
{
    "error": "Account failed to create!"
}

Validate local Loginserver account credentials

Request Body

{
    "username": "test",
    "password": "test",
    "email": "<optional>"
}

Responses

{
    "data": {
        "account_id": 3,
    },
    "message": "Credentials valid!"
}
{
    "error": "Credentials invalid!"
}

Update local Loginserver account credentials

Request Body

{
    "username": "test",
    "password": "test",
}

Responses

{
    "message": "Loginserver account credentials updated!"
}
{
    "error": "Failed to find associated loginserver account!"
}
{
    "error": "Failed to update loginserver account credentials!"
}

World Servers

Example

BaseURL http://loginserver:6000

Header Authorization: Bearer <token>

Lists connected worldservers (memory)

Result

[
    {
        "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
    }
]