WebSocket API
The WebSocket API is the interface that the Biz3 (biz.candyhouse.co) management console uses to talk to the cloud: device management, device operations, members and permissions, access-control credentials (cards / passcodes), developer settings and more.
Note
This document is compiled from the Biz3 source code (src/api, src/websocket). Fields reflect what the client actually sends and reads; the server may return more. The interface changes as Biz3 is updated.
Connection
| Item | Value |
|---|---|
| URL | wss://82q6nuplv0.execute-api.ap-northeast-1.amazonaws.com/public |
| Protocol | WebSocket (JSON text messages) |
Pass the token as a query parameter when connecting:
wss://82q6nuplv0.execute-api.ap-northeast-1.amazonaws.com/public?token=<JWT>&lang=<language>| Parameter | Description |
|---|---|
token | Required. The signed-in user's Cognito ID Token (JWT), URL-encoded |
lang | UI language such as ja, en, zh-CN, zh-TW; server messages are returned in this language |
Authentication
Sign in with a CANDY HOUSE account through Amazon Cognito (user pool) and use the ID Token (JWT) as token. The JWT's sub is the account ID (subUUID in Biz). Refresh the token and reconnect when it expires.
Message format
Request
Every request is a single JSON message. action selects the API category, op selects the operation, and the remaining fields are parameters:
{
"action": "biz3ManageDevice",
"op": "getDeviceStatus",
"deviceUUID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}Response
The server replies with the same action (and op):
{
"action": "biz3ManageDevice",
"op": "getDeviceStatus",
"success": true,
"data": {}
}| Field | Description |
|---|---|
action / op | Same as the request; used to match the request |
success | Whether the request succeeded |
data | Response data; see each API |
message | Error message on failure, e.g. Limit Exceeded when the device limit is reached |
code | Error code returned by some APIs (e.g. 406 from the IR remote APIs means no data) |
reqContext | Request parameters echoed back by the server (e.g. name, deviceUUID from the request); useful for matching a response to its request |
Messages carry no request ID: responses for the same action + op correspond to requests in the order they were sent. The server may also push messages on its own (e.g. device status changes).
Heartbeat and reconnection
- Send a heartbeat
{"action": "biz3KeepAlive"}every 5 minutes; the reply containsconnectionId. If there is no reply within 3 seconds, treat the connection as dead and reconnect. - A connection not established within 5 seconds is considered timed out. After a disconnect, reconnect with a 1–10 second backoff; after repeated failures, first check whether the token has expired.
- Messages to be sent while disconnected can be queued and sent after reconnecting; do not resend a previous account's messages after switching accounts.
