WebSockets

Consume live metrics via WebSocket.

Connecting

Create a new WebSocket connection. Provide a Floor ID and receive metrics for spaces on that floor. See details here:

Stream Data

After connecting to your WebSocket, receive updates when a space's presence status/occupancy changes or when a space's health status changes. See Space and Device Health for details on space health.

The update_type denotes whether an update is a live update or a full space list refresh update. The WebSocket will send a refresh once a minute. counting_mode denotes the sensor type that triggered the update. Either oa or entry * We only support presence for Open Area sensors and occupancy for Entry sensors at this time

WebSocket events are in the following JSON format:

Example refresh response for OA Presence

Copy
Copied
{
    "update_type": "refresh",
    "data": {
        "spc_12345": {
            "timestamp": "2023-12-01T03:09:38Z",
            "presence": false,
            "counting_mode": "oa",
            "space_health_status": "healthy"
        },
        "spc_1678910": {
            "timestamp": "2023-12-01T13:18:20Z",
            "presence": true,
            "counting_mode": "oa",
            "space_health_status": "healthy"
        }
    }
}

Example live response

Copy
Copied
{
    "update_type": "live",
    "data": {
        "spc_12345": {
            "timestamp": "2023-12-01T03:09:38Z",
            "presence": true,
            "counting_mode": "oa",
            "space_health_status": "healthy"
        }
    }
}

Example refresh response for Entry Occupancy

Copy
Copied
{
    "update_type": "refresh",
    "data": {
        "spc_12345": {
            "timestamp": "2023-12-01T03:09:38Z",
            "occupancy": 0,
            "counting_mode": "entry",
            "space_health_status": "healthy"
        },
        "spc_1678910": {
            "timestamp": "2023-12-01T13:18:20Z",
            "occupancy": 1,
            "counting_mode": "entry",
            "space_health_status": "healthy"
        }
    }
}

Example live response

Copy
Copied
{
    "update_type": "live",
    "data": {
        "spc_12345": {
            "timestamp": "2023-12-01T03:09:38Z",
            "occupancy": 1,
            "counting_mode": "entry",
            "space_health_status": "healthy"
        }
    }
}