Skip to content

API Spec

JoJoJux edited this page Jul 19, 2023 · 3 revisions

This is the specification that is used by rust and the frontend to communicate with the server via HTTP.

API-Spec HTTP

GET /activate/<CHANNEL>

Report that a device listening <CHANNEL> is now active.

[SUC] Result Success

{
    "success": "Channel was activated."
}

[ERR] Result Channel already listening

{
    "error": "Channel is already being listened on.",
    "error_id": 2
}

GET /loose/<CHANNEL>

Report that the device listening <CHANNEL> is no longer active.

[SUC] Result Success

{
    "success": "Channel was deactivated."
}

[ERR] Result Channel not listening

{
    "error": "Channel is not being listened on.",
    "error_id": 2
}

GET /get/<CHANNEL>

Get all data the server has about the device listening <CHANNEL>.

[SUC] Result Success

The actions list is a list of all actions that were requested via the /action/<CHANNEL>-endpoint.

{
    "actions": [],
    "channel": <CHANNEL>
}

[ERR] Result Channel not listening

{
    "error": "Channel is not being listened on.",
    "error_id": 2
}

GET /pending/<CHANNEL>

Get all actions the server was given for the device listening <CHANNEL> via the /action/<CHANNEL>-endpoint.

[SUC] Result Success

The list is a list of all actions that were requested via the /action/<CHANNEL>-endpoint.

[]

[ERR] Result Channel not listening

{
    "error": "Channel is not being listened on.",
    "error_id": 2
}

GET /pop/<CHANNEL>

Get the oldest action the server was given for the device listening <CHANNEL> via the /action/<CHANNEL>-endpoint.

[SUC] Result Success

The obj is the data submitted to actions that were requested via the /action/<CHANNEL>-endpoint.

{
    "next_action": {}
}

[SUC] Result No actions

The obj is the data submitted to actions that were requested via the /action/<CHANNEL>-endpoint.

{
    "next_action": "idle"
}

[ERR] Result Channel not listening

{
    "error": "Channel is not being listened on.",
    "error_id": 2
}

GET /action/<CHANNEL>

Add an action to the queue for the device listening the channel <CHANNEL>.

[SUC] Result Success

The obj is the data submitted to actions that were requested via the /action/<CHANNEL>-endpoint.
Takes unspecified query arguments. These are converted to a dict and shown in the response as json in action, as well as added to the queue.

{
    "action": {},
    "success": "The action was added to the queue"
}

[ERR] Result Channel not listening

{
    "error": "Channel is not being listened on.",
    "error_id": 2
}

GET /get

Get all data the server has saved about devices.

[SUC] Result Success

Returns an object of channel:device, each containing the corresponding response of /get/<CHANNEL>

{}
<p><h2><a href="http://212.227.8.25:8123/logs">/log/0</a></h2>
This will show the list of recoreded signals.
<h3>Responses:</h3>
<h4>Success</h4>
<pre>
    {
        "signals": [] // the format used with the get args
    }
</pre>
</p>

<p><h2><a href="http://212.227.8.25:8123/logs">/logs</a></h2>
This will show the list of recoreded signals.
<h3>Responses:</h3>
<h4>Success</h4>
<pre>
    {
        "signals": [] // the format used with the get args
    }
</pre>
</p>