Welcome to the Softlab Relay Server API! This platform provides ultra-low latency, bidirectional WebSocket communication designed specifically for remote hardware automation (e.g., controlling a Raspberry Pi via a PC/Bot).
All clients (both Commanders and Workers) connect to the same central endpoint. The server handles routing messages between clients based on their API keys and target IDs.
wss://)wss://relay.softlab.ee/ws/connect/Security is enforced at the connection level. You cannot send commands until you complete the authentication handshake.
Immediately upon opening the WebSocket connection, the client must send an authentication payload. You can use either a Master API Key (for controllers/bots) or a Device Token (for hardware).
Option A: Master API Key (Requires sender ID)
{
"auth_key": "YOUR_RAW_MASTER_KEY",
"sender": "my_controller_id"
}
Option B: Device Token (ID is pre-assigned)
{
"device_token": "YOUR_DEVICE_TOKEN"
}
The server verifies the credentials and assigns the socket to a secure, isolated room.
{
"status": "authenticated",
"client_id": "my_controller_id"
}
Note: Once authenticated, you do not need to include credentials in subsequent messages.
The following are default limits. Administrators can increase these on a per-user basis (e.g., for enterprise customers or specialized hardware).
{"action": "ping"} will return {"status": "pong"}.auth_key, device_token, or sender (for Master Keys) was missing.Once authenticated, clients can freely pass messages to one another. The relay acts as a blind switchboard—it looks at the target field and forwards the entire JSON payload to that specific client ID.
If a message is sent to a target that is offline, the server queues it (default capacity is 50 messages and 24-hour TTL, but this can be increased per user). These are delivered upon the target's next login with a "_offline_queued": true flag added to the payload.
{
"target": "mouse_pi",
"sender": "tkinter_bot",
"priority": "highest",
"speed": 100,
"subtasks": "Mx1920y1080 / C"
}
While most communication happens via WebSockets, you can check the real-time status of multiple devices via a standard HTTP GET request. This is primarily used by the dashboard but is available for any authenticated session.
https://relay.softlab.ee/api/presence/GETdevices=device_id1,device_id2{
"mouse_pi": "online",
"sensor_pi": "offline"
}
run_forever) in a dedicated thread or asynchronous loop.is_authenticated = False) in your client.{"action": "ping"} every 30-60 seconds to keep the connection active.Choose your preferred programming language to see a minimal implementation for both Commanders and Workers.
For Python developers, we provide a production-ready client wrapper that handles authentication, heartbeats, and reconnection.
Download: relay_client.py
from relay_client import SoftlabRelayClient
def on_data(data):
print(f"Message received: {data}")
# Commander Example
client = SoftlabRelayClient(
auth_key="YOUR_MASTER_KEY",
sender="my_pc",
on_message=on_data
)
client.start()
# Send a message
client.send_message("mouse_pi", {"command": "move", "x": 100})