WebSocket (/ws/v1)
The address is ws://<IP>:<port>/ws/v1. No authentication is required, and the client sends nothing.
Server messages
Section titled “Server messages”{ "type": "snapshot", "source": { "type": "vmix", "state": "ready", "error": null }, "devices": [{ "id": "k3m9x2qa", "name": "Camera 1", "program": true, "preview": false }]}{ "type": "heartbeat" }- A
snapshotarrives as soon as the connection opens. - Any change (tally, cameras added, changed or removed, switcher state) sends a full
snapshot. A snapshot identical to the last one is not sent. - A
heartbeatarrives every 2 seconds. - If a connection’s send buffer overflows, the server closes it. After reconnecting, the client receives the latest snapshot.
Client rules
Section titled “Client rules”- No message for 6 seconds: show Unknown, close and reconnect.
- After a disconnect, retry every 2 seconds, and immediately when the app or page returns to the foreground. Each reconnect brings a new full snapshot; replace the old state with it.
- If your camera ID is not in the snapshot, show “Camera deleted”.
Example
Section titled “Example”let ws, watchdogfunction connect() { ws = new WebSocket(`${base.replace(/^http/, 'ws')}/ws/v1`) const alive = () => { clearTimeout(watchdog) watchdog = setTimeout(lost, 6000) } const lost = () => { ws.onmessage = ws.onclose = null ws.close() clearTimeout(watchdog) show('unknown') setTimeout(connect, 2000) } alive() ws.onmessage = (event) => { alive() const message = JSON.parse(event.data) if (message.type === 'snapshot') show(tallyOf(message, deviceId)) } ws.onclose = lost}connect()For tallyOf, see Display rules.