Skip to content

Account State API

Don Cato edited this page Jan 5, 2022 · 6 revisions

Info

The Information of the current state of an account is shared by basic Http-POST requests containing the Payload or Data as JSON in the Body To update the state of an account the /api/infos endpoint is used

Types of Messages

At the moment these Types of Messages are thought to be used and useful.

The type of the given POST Message is given by a Header called Message-Type which value (called Type-ID) is numerical, the Server responds with one of the described return status codes

A lot of Messages will contain additional, partially optional, information, such as a Epoch Timestamp [T], Location [L], and seconds since/till last/next interaction [Tp]/[Td] or other [O], specified below:

Type-ID Name Function Body Returns
0 TEST Tests if a Beacon Signal would work 200 400 401 500 503
1 AUDIT Sends a Payload to the Server which should be Logged T,L,Tp,Td,O 200 400 401 500 503
2 SIGN Signals the unavailability of the User T,Tp 200 304 400 401 500 503
3 ILIVE Indicates the Client/User is still active/alive T,Td 200 400 401 409 500 503
4 STAT Checks for information of the Server 200+R 400 401 404 503

Notes

In the occurence that the User is to be assumed as Deceased or Unavailable, a last AUDIT Message should be sent BEFORE the SIGN message, as the AUDIT Message contains the valuable information and set the Time for the next expected Message relatively short

Request Body

The Request Body can have different fields. The following are the required data Types for each field.

Field Name [Key] Value Description Limitations
T INT Current time as UNIX timestamp Can't be in the future
Tp INT Seconds since last message /
Td INT Seconds till the next message shall be expected /
L [STRING] Geo Location /
O {STRING: [STRING]} Miscellaneous Information /

Examples

Requests with No Special Answer [0-3]

Requests

POST /api HTTP/1.1
Host: example.com
Content-Type: application/json

Auth-Token: <your_token>
Message-Type: 0
---
{}
POST /api HTTP/1.1
Host: example.com
Content-Type: application/json

Auth-Token: <your_token>
Message-Type: 1
---
{
   "T": <Unix Timestamp>,
   "Tp": <Seconds Since Last Interaction/SignOfLife>,
   "Td": <Seconds until the next Message to be expected by the Server>,
   "L": ["<Latitude>", "<Longitude>"],
   "O": {
   // These are just Examples anything useful can be used here.
      "WIFI": ["<Detected WIFI Networks>", ...],
      "BT": ["<Detected Bluetooth Devices>", ...],
      "NET": ["<Connected Cellphone/Transmission Tower>", ...],
      "BPM": ["<Pulse of the User>", ...],
      "O2": ["<Oxygen Concentration>", ...],
      "BATT": ["<Battery Status>", ...],
      ...
   },

}
POST /api HTTP/1.1
Host: example.com
Content-Type: application/json

Auth-Token: <your_token>
Message-Type: 2
---
{
   "T": <Unix Timestamp>,
   "Td": <Seconds Since Last Interaction/SignOfLife>
}
POST /api HTTP/1.1
Host: example.com
Content-Type: application/json

Auth-Token: <your_token>
Message-Type: 3
---
{
   "T": <Unix Timestamp>,
   "Td": <Seconds until the next Message to be expected by the Server>,
}

Responses

200 304 400 401 405 500 503

Requests with Information returned [4]

Requests

POST /api HTTP/1.1
Host: example.com
Content-Type: application/json

Auth-Token: <your_token>
Message-Type: 4
---
{}

Responses

{
    "status": 200,
    "content": {
        "Status": {
             "Hostname": "A PC",
             "Description": "Running DMNB",
             "Account": "foo@example.com",
             "Uptime": 1,
             "Maintenace": -1
        }
    }
}

or one of the following: 400 401 500 503