Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

API Reference

Jannik Emmerich edited this page Feb 22, 2021 · 6 revisions

User Endpoints

Contact MicroService

Contact a MicroService Endpoint

Request:

{
  "tag":"<tag of the request [string, UUID]>",
  "ms":"<microservice [string]>",
  "endpoint":"<microservice endpoint [string]>",
  "data":"<data sent to the microservice [JSON]>"
}

Response:

{
  "tag":"<tag of the request [string, UUID]>",
  "data":"<data sent by the microservice [JSON]>"
}

Errors:

  • microservice did not answer
{
  "error":"timeout"
}

Status Action

Get the Number of Online Players

Request:

{
  "action":"status"
}

Response:

{
  "online":"<number of online players [number]>"
}

Setting Action

Add or Modify Setting

Request:

{
  "action":"setting",
  "key":"<key [string]>",
  "value":"<value [string]>"
}

Response:

{
  "key":"<key [string]>",
  "value":"<value [string]>"
}

Errors:

  • the key or the value is to long
{
  "error":"unsupported parameter size"
}

Get Setting

Request:

{
  "action":"setting",
  "key":"<key [string]>"
}

Response:

{
  "key":"<key [string]>",
  "value":"<value [string]>"
}

Errors:

  • the setting does not exist
{
  "error":"unknown setting"
}

Delete Setting

Request:

{
  "action":"setting",
  "key":"<key [string]>",
  "delete":""
}

Response:

{
  "success":true
}

Errors:

  • the setting does not exist
{
  "error":"unknown setting"
}

Login Action

Log In Using the Access Data

Request:

{
  "action":"login",
  "name":"<username [string]>",
  "password":"<password [string]>"
}

Response:

{
  "token":"<session token [string, UUID]>"
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}
  • wrong password or nonexistent user
{
  "error":"permissions denied"
}

Logout Action

Log Out

Prerequisite: the user must be logged in

Request:

{
  "action":"logout"
}

Response:

{
  "status":"logout"
}

Session Action

Log In Using a Valid Session Token

Request:

{
  "action":"session",
  "token":"<session token [string, UUID]>"
}

Response:

{
  "token":"<session token [string, UUID]>"
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}
  • token is not valid
{
  "error":"invalid token"
}

Register Action

Create a New Account

Request:

{
  "action":"register",
  "name":"<username [string]>",
  "password":"<password [string]>"
}

Response:

{
  "token":"<session token [string, UUID]>"
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}
  • password does not meet the requirements
{
  "error":"invalid password"
}
  • mail address does not meet the requirements
{
  "error":"invalid email"
}
  • username already exists
{
  "error":"username already exists"
}

Password Action

Change the password of the user

Request:

{
  "action":"password",
  "name":"<username [string]>",
  "password":"<old password [string]>",
  "new":"<new password [string]>",
}

Response:

{
  "success":true
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}
  • password is not correct, new password does not meet the requirements or the user does not exists
{
  "error":"permissions denied"
}

Info Action

Get Information About the Logged-In User

Prerequisite: the user must be logged in

Request:

{
  "action":"info"
}

Response:

{
  "name":"<username [string]>",
  "uuid":"<uuid of the user [string, UUID]>",
  "mail":"<mail address [string]>",
  "created":"<timestamp when the user was created [number]>",
  "last":"<timestamp when the user was last logged in [number]>",
  "online":"<number of online players [number]>
}

Delete Action

Delete the Logged-In User

Prerequisite: the user must be logged in

Request:

{
  "action":"delete"
}

Response:

{
  "status":"logout"
}

MicroService Endpoints

Register Action

Register a New MicroServer

Request:

{
  "action":"register",
  "name":"<name of the microservice [string]>"
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}

Address Action

Send Data to a User

Request:

{
  "action":"address",
  "user":"<uuid of the user [string, UUID]>",
  "data":"<data sent to the user [JSON]>"
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}

User Action

Get Information About a user

Request:

{
  "action":"user",
  "tag":"<uuid of the request [string, UUID]>",
  "data":{"user":"<uuid of the user [string, UUID]>"}
}

Response:

  • user is not valid
{
  "tag":"<uuid of the request [string, UUID]>",
  "data":{"valid":false}
}
  • user is valid
{
  "tag":"<uuid of the request [string, UUID]>",
  "data":
    {
      "valid":true,
      "uuid":"<uuid of the user [string, UUID]>",
      "name":"<username of the user [string]>",
      "mail":"<mail address of the user [string]>",
      "created":"<timestamp when the user was created [number]>",
      "last":"<timestamp when the user was last logged in [number]>"
    }
}

Errors:

  • missing parameters
{
  "error":"missing parameters"
}