Schemas
Every SBE message starts with the standard SBE
messageHeader (blockLength:uint16, templateId:uint16, schemaId:uint16, version:uint16). Use schemaId and templateId to select the decoder. On the wire, each SBE message is carried inside a TCP frame that adds a framing header in front of the SBE messageHeader — see Framing.
Compatibility rule: new optional or versioned fields require a schema version increase. Existing field and template IDs are never reused or reordered.
Connections
The session uses two connections. EachcompId allows one active live connection and one active snapshot connection.
- Snapshot connection — send a
SubscriptionRequestwithsubscriptionRequestType=Snapshotto receive one snapshot (instrument definitions, order book or, on Spot and Futures only, trading session status). - Live connection — send
SubscribeorUnsubscribeto start or stop incremental delivery for a feed.
MarketDataFeed: InstrumentDefinition, OrderBookL3, Trade, InstrumentStatus and TradingSessionStatus.
TradingSessionStatus applies to Spot and Futures, not to US Perps. US Perps does not expose a global trading session status. It provides the status per instrument: use the InstrumentStatus feed, and the status carried by each InstrumentDefinition.Framing
Each TCP frame carries exactly one SBE message, in both directions. TLS protects the TCP stream but does not change the frame bytes.
The first six bytes are the Simple Open Framing Header (SOFH). The eight-byte Kraken TCP header is a Kraken extension to the usual SOFH and SBE layout: a generic SOFH reader must skip those eight bytes before decoding the SBE
messageHeader.
SendingTimeis diagnostic only. The gateway stamps a shared market data frame once, when it enters the shared fanout, so every client sees the same time for that frame. It is not a kernel transmit timestamp, and it must not be used for authentication or replay checks.- Reading frames. TCP may split one frame across several reads or return several frames in one read. Read the full SOFH, check its fields, then wait until
messageLengthbytes have arrived. - Protocol errors. An unsupported
encodingType, amessageLengthbelow 22 (the minimum frame size), or amessageLengthabove the service limit is a protocol error. Kraken closes the connection instead of skipping the frame. - Repeating groups. Before reading a group, verify that its block length and entry count fit inside the enclosing frame. Check the size arithmetic for overflow.
Frame counting
Frame counting is implicit: there is no sequence number on the wire for session control.- Each direction has its own counter. Both start at 1 on a new connection, never wrap, and have no daily reset.
- A sender advances its counter after it successfully sends a complete frame. A receiver advances its counter after it validates the complete SOFH and SBE frame.
- Every frame counts, including negotiation, subscription, heartbeat, termination and market data messages. Zero means no frame has been received.
AdminHeartbeat.lastReceivedClientSequencereports the latest client frame Kraken accepted, andSubscriberHeartbeat.lastReceivedServerSequencereports the latest server frame the client processed.- An acknowledgement greater than the number of frames its peer has sent is a protocol violation. A lower value is allowed while frames are in flight or waiting to be processed; persistent lag is handled by the service’s slow consumer limits.
- Heartbeat acknowledgements never request a replay. After a broken connection, start a new session and request a fresh snapshot.
Session schema (ID 33)
Enumerations and encodings: Session enums & encodings.
Market data schema (ID 34)
Enumerations and encodings: Market data enums & encodings.
Sequencing
Incremental feeds carry contiguous per-instrument (or per-feed) sequence numbers starting at one —orderBookSeq, tradeSeq, instrumentStatusSeq, instrumentDefinitionSeq and tradingSessionSeq. Snapshots carry the last sequence number they include (for example lastOrderBookSeqProcessed), so you can apply buffered incrementals with a higher sequence number on top of the snapshot.
Gap recovery
There is no message replay. When you detect a gap, request a new snapshot on the snapshot connection and rebuild from it:There is no trade snapshot. A gap in
tradeSeq can be detected, but trades missed during the gap, or while you were disconnected, cannot be recovered from a book snapshot or any other feed.Related
US Perps API overview
How order entry, market data and drop copy fit together.
Unified FIX v2
FIX 4.4 order entry for US Perps.
Drop Copy
FIX 4.4 copy of every execution report on your account.
US Perps connectivity
Connectivity and colocation documents.