Skip to main content

WebSocket Protocol

Senticore WebSocket channels use a multiplexed JSON protocol over a single TLS connection.

Connection

EnvironmentEndpoint
Public beta streamswss://stream.beta.sentico-labs.xyz/public
Private beta streamswss://stream.beta.sentico-labs.xyz/private
Mainnet streamswss://stream.sentico-labs.xyz after public launch

Private streams require an authenticated handshake. See Authentication.

Message envelope

Every data message follows a stable envelope:

{
"channel": "l2Book",
"market": "BTC-USDC",
"seq": 184273,
"prevSeq": 184272,
"schemaId": "l2Book.v1",
"schemaVersion": 1,
"schemaEncoding": "json",
"ts": 1730000000000,
"data": {}
}
FieldPurpose
channelChannel name
marketMarket identifier when channel-specific
seqMonotonic sequence within the channel scope
prevSeqPrevious sequence used for gap detection
schemaId / schemaVersionSchema identity for compatibility checks
schemaEncodingjson for current public streams
tsServer timestamp in unix milliseconds
dataChannel-specific payload

Subscribe and unsubscribe

{
"op": "subscribe",
"channels": [
{"channel": "l2Book", "market": "BTC-USDC"},
{"channel": "trades", "market": "BTC-USDC"}
]
}

Server acknowledgement:

{
"op": "subscribed",
"channels": [
{"channel": "l2Book", "market": "BTC-USDC"},
{"channel": "trades", "market": "BTC-USDC"}
]
}

Unsubscribe uses the same channel selector:

{
"op": "unsubscribe",
"channels": [
{"channel": "trades", "market": "BTC-USDC"}
]
}

Heartbeat

The server sends a heartbeat every 30 seconds:

{"op": "ping", "ts": 1730000000000}

The client must respond within 10 seconds:

{"op": "pong", "ts": 1730000000123}

Missed pongs close the connection.

Sequence handling

Consumers must:

  • verify seq == prevSeq + 1 for every scoped stream
  • trigger resync on a gap, checksum mismatch, or resync_required
  • fetch a fresh REST snapshot before applying new deltas
  • resume private streams from the last acknowledged account sequence where available

Error model

Errors arrive as control messages:

{
"op": "error",
"code": "resync_required",
"channel": "l2Book",
"market": "BTC-USDC",
"message": "client lag exceeded retention window"
}
CodeClient action
resync_requiredFetch a snapshot, resubscribe, and replay from fresh state
auth_failedReconnect with valid credentials
rate_limitedBack off per retry guidance
unknown_channelCorrect the subscription request
permission_deniedRequest the required account or institutional permission

Resilience

See Reconnect Strategy for production-grade client behavior.