Exchange Wire Formats

OKX Spot wire format

This page shows how OKX spot (SPOT) messages become rows in our Parquet files. For each data type below, you see a real message next to the rows that we publish for it. The page also gives the source and the rule for each column. Put the pointer on a line or a column to see how they connect.

Checked against our pipeline

We recorded these messages from OKX spot (SPOT) on 2026-10-05. Our test suite replays each message through the production collector parser and the postprocessor. The test fails if the published rows are different from the rows on this page. Files that we wrote before a change to the pipeline can be different. Refer to Known Gaps & Corrections.

The collector subscribes to each channel for each instrument with {"channel": …, "instId": "BTC-USDT"}. OKX Spot uses the same message formats and postprocessor as OKX Futures. Spot sizes are in the base asset.

  • Public WebSocket (books, tickers): wss://ws.okx.com:8443/ws/v5/public
  • Business WebSocket (trades-all): wss://ws.okx.com:8443/ws/v5/business

Exchange API reference: www.okx.com. For the conventions that apply to all exchanges, refer to the wire formats overview.

Trades

One row per fill from the trades-all channel.

  • WebSocket trades-all

Each trades-all message contains exactly one fill.

WebSocket message · trades-allreceived 2026-10-05 19:14:59.976916 UTC
{
"arg": {
"channel": "trades-all",
"instId": "BTC-USDT"
},
"data": [
{
"instId": "BTC-USDT",
"tradeId": "1066842395",
"px": "85668.8",
"sz": "0.00015743",
"side": "buy",
"ts": "1791227699299",
"source": "0"
}
]
}

Published row

received_time1791227699976916000—Our collector's clock when it received the message, in nanoseconds since the Unix epoch. OKX does not send this value.
event_time1791227699299data[].tsCopied from the fill time. Milliseconds.
symbolBTC-USDTdata[].instIdCopied.
trade_id1066842395data[].tradeIdParsed from the OKX string to an integer.
price85668.8data[].pxCopied as the exact decimal string that OKX sent.
quantity0.00015743data[].szCopied as the exact decimal string. Base asset units.
trade_time1791227699299data[].tsCopied. Milliseconds. The same value as event_time.
is_buyer_makerfalsedata[].sidetrue if side is sell (the taker sold, thus the buyer was the maker). false if side is buy.
order_typeMARKET—Always MARKET. This is a placeholder value because OKX does not send an order type.

Notes

  • The rows come from the trades-all channel on the business endpoint. This channel sends one entry for each fill. The public trades channel sends one entry for each taker order, fill price and order source. We stopped the use of the trades channel in the 2026-09 data-integrity release (refer to the venue notes).
  • The rows in a file are sorted by trade_time, then by trade_id. We publish each trade_id only one time in an hour file.
  • We do not publish the OKX source field (0 is a normal order, 1 is an Enhanced Liquidity Program order).

For the column types and descriptions, refer to the Trades schema.

Order Book

One row per price level from the 400-level books channel. OKX sends a snapshot after the subscription, then updates at 100 ms intervals.

  • WebSocket books

Order book snapshot (action: snapshot)

OKX sends a 400-level snapshot immediately after the subscription. This snapshot is the start of the update chain. Its prevSeqId is always -1.

Shortened: OKX sent 400 bid levels and 400 ask levels in this message. This example shows the best three of each.

WebSocket message · booksreceived 2026-10-05 19:15:00.149844 UTC
{
"arg": {
"channel": "books",
"instId": "BTC-USDT"
},
"action": "snapshot",
"data": [
{
"asks": [
["85668.8", "0.60167743", "0", "24"],
["85669.8", "0.04202294", "0", "1"],
["85670.7", "0.19024141", "0", "1"]
],
"bids": [
["85668.7", "0.15616065", "0", "6"],
["85667.8", "0.0000102", "0", "1"],
["85667.4", "0.00001172", "0", "1"]
],
"ts": "1791227700007",
"checksum": 0,
"seqId": 82018808615,
"prevSeqId": -1
}
]
}

Published rows · 6

received_time1791227700149844000—Our collector's clock when it received the message, in nanoseconds since the Unix epoch. OKX does not send this value.
event_time1791227700007data[].tsCopied from the time when OKX generated the order book. Milliseconds.
transaction_timenull—Null. OKX sends only one order book timestamp.
symbolBTC-USDTarg.instIdCopied.
event_typesnapshotactionsnapshot when action is snapshot.
first_update_idnull—Null. OKX sends no first update ID.
final_update_id82018808615data[].seqIdCopied from seqId.
prev_final_update_idnull—Null for snapshots. A snapshot starts a new chain.
last_update_id-1data[].prevSeqIdCopied from prevSeqId, which is always -1 for a snapshot. We keep this column for the files that we wrote before we added prev_final_update_id.
sidebiddata[].bidsdata[].asksbid for levels in bids, ask for levels in asks. One row per level.
price85668.7data[].bids[][0]data[].asks[][0]Copied as the exact decimal string.
quantity0.15616065data[].bids[][1]data[].asks[][1]Copied as the exact decimal string. Base asset units.
order_count6data[].bids[][3]data[].asks[][3]Copied as an integer from the fourth element of the level (number of orders). OKX does not use the third element now (always 0), and we do not publish it.

Order book update (action: update)

Incremental changes. OKX sends them every 100 ms when the order book changes. The prevSeqId of each update is equal to the seqId of the previous message.

Shortened: OKX sent 11 bid levels and 6 ask levels in this message. This example shows two bids and two asks. One of these levels has quantity 0, which removes the level.

WebSocket message · booksreceived 2026-10-05 19:15:00.247388 UTC
{
"arg": {
"channel": "books",
"instId": "BTC-USDT"
},
"action": "update",
"data": [
{
"asks": [
["85670.3", "0.0000102", "0", "1"],
["85755.7", "0", "0", "0"]
],
"bids": [
["85659.9", "0.06542374", "0", "3"],
["85657", "0.00448811", "0", "2"]
],
"ts": "1791227700107",
"checksum": 0,
"seqId": 82018808663,
"prevSeqId": 82018808615
}
]
}

Published rows · 4

received_time1791227700247388000—Our collector's clock when it received the message, in nanoseconds since the Unix epoch. OKX does not send this value.
event_time1791227700107data[].tsCopied from the time when OKX generated the order book. Milliseconds.
transaction_timenull—Null. OKX sends only one order book timestamp.
symbolBTC-USDTarg.instIdCopied.
event_typeupdateactionupdate when action is update.
first_update_idnull—Null. OKX sends no first update ID.
final_update_id82018808663data[].seqIdCopied from seqId.
prev_final_update_id82018808615data[].prevSeqIdCopied from prevSeqId. It is equal to the final_update_id of the previous message. If the two values are different, there is a gap.
last_update_id82018808615data[].prevSeqIdCopied from prevSeqId, the same value as prev_final_update_id. We keep this column for the files that we wrote before we added prev_final_update_id.
sidebiddata[].bidsdata[].asksbid for levels in bids, ask for levels in asks. One row per level.
price85659.9data[].bids[][0]data[].asks[][0]Copied as the exact decimal string.
quantity0.06542374data[].bids[][1]data[].asks[][1]Copied as the exact decimal string. It is the new total at that price. 0 removes the level. Base asset units.
order_count3data[].bids[][3]data[].asks[][3]Copied as an integer from the fourth element of the level (number of orders).

Snapshot of an empty order book

A snapshot with no bid levels and no ask levels. We captured it on the quiet AUDF-USDT pair. It is still the start of the sequence chain. Thus, we publish it as one marker row with side noop. If an update has no levels and its seqId is different from prevSeqId, we publish it in the same way, as an update marker row.

WebSocket message · booksreceived 2026-10-05 19:15:41.842255 UTC
{
"arg": {
"channel": "books",
"instId": "AUDF-USDT"
},
"action": "snapshot",
"data": [
{
"asks": [],
"bids": [],
"ts": "1791227741701",
"checksum": 0,
"seqId": 696923,
"prevSeqId": -1
}
]
}

Published row

received_time1791227741842255000—Our collector's clock when it received the message, in nanoseconds since the Unix epoch. OKX does not send this value.
event_time1791227741701data[].tsCopied. Milliseconds.
transaction_timenull—Null. OKX sends only one order book timestamp.
symbolAUDF-USDTarg.instIdCopied.
event_typesnapshotactionsnapshot when action is snapshot.
first_update_idnull—Null. OKX sends no first update ID.
final_update_id696923data[].seqIdCopied from seqId.
prev_final_update_idnull—Null for snapshots.
last_update_id-1data[].prevSeqIdCopied from prevSeqId (-1 for a snapshot).
sidenoop—noop. The message has no levels, thus one marker row keeps its sequence ID.
price0—0 on the marker row.
quantity0—0 on the marker row.
order_countnull—Null on the marker row.

Keepalive update (not published)

If an order book does not change for about 60 seconds, OKX sends an update with no levels and with seqId equal to prevSeqId. This update changes nothing, and we do not publish it. We captured it on AUDF-USDT. The same is true for swaps.

WebSocket message · booksreceived 2026-10-05 19:16:00.142279 UTC
{
"arg": {
"channel": "books",
"instId": "AUDF-USDT"
},
"action": "update",
"data": [
{
"asks": [],
"bids": [],
"ts": "1791227760001",
"checksum": 0,
"seqId": 696923,
"prevSeqId": 696923
}
]
}

Not published

received_time—Not published. The message has no levels and does not move the sequence forward.
event_time—Not published. The message has no levels and does not move the sequence forward.
transaction_time—Not published. The message has no levels and does not move the sequence forward.
symbol—Not published. The message has no levels and does not move the sequence forward.
event_type—Not published. The message has no levels and does not move the sequence forward.
first_update_id—Not published. The message has no levels and does not move the sequence forward.
final_update_id—Not published. The message has no levels and does not move the sequence forward.
prev_final_update_id—Not published. The message has no levels and does not move the sequence forward.
last_update_id—Not published. The message has no levels and does not move the sequence forward.
side—Not published. The message has no levels and does not move the sequence forward.
price—Not published. The message has no levels and does not move the sequence forward.
quantity—Not published. The message has no levels and does not move the sequence forward.
order_count—Not published. The message has no levels and does not move the sequence forward.

Notes

  • OKX stopped the books checksum in 2026. OKX still sends the field, but it is always 0 and we do not publish it. seqId/prevSeqId is the only continuity check. An update continues the order book if its prev_final_update_id is equal to the final_update_id of the previous message. All rows of one message have the same two IDs. Thus, do the check one time for each message, not for each row.
  • OKX documentation states that seqId can start again at a lower value after maintenance. prevSeqId is still equal to the seqId of the previous message. Thus, compare each prevSeqId with the previous seqId. Do not use an increase of seqId as the check.
  • The collector makes sure that the chain is correct before it writes the data. After a gap, it connects again and starts from a new WebSocket snapshot.
  • Quantities are in the base asset.
  • On a new listing, the best ask can be below the best bid before continuous trading starts (OKX openType call_auction or pre_quote). The collector accepts a crossed order book only in that period: from the listTime of the instrument to its contTdSwTime (OKX GET /api/v5/public/instruments).
  • A file can start with a checkpoint snapshot of the order book that continues from the previous hour. In this snapshot, received_time is the start of the hour and transaction_time is null. final_update_id and last_update_id are both the last seqId that we applied.

For the column types and descriptions, refer to the Order Book schema.

Ticker

One row per tickers message.

  • WebSocket tickers
WebSocket message · tickersreceived 2026-10-05 19:15:00.014684 UTC
{
"arg": {
"channel": "tickers",
"instId": "BTC-USDT"
},
"data": [
{
"instType": "SPOT",
"instId": "BTC-USDT",
"last": "85668.8",
"lastSz": "0.00047965",
"askPx": "85668.8",
"askSz": "0.60167743",
"bidPx": "85668.7",
"bidSz": "0.15659044",
"open24h": "85389.7",
"high24h": "86994.3",
"low24h": "84979.5",
"sodUtc0": "86522.4",
"sodUtc8": "85267.6",
"volCcy24h": "557320377.998248583",
"vol24h": "6475.49027556",
"ts": "1791227699768"
}
]
}

Published row

received_time1791227700014684000—Our collector's clock when it received the message, in nanoseconds since the Unix epoch. OKX does not send this value.
event_time1791227699768data[].tsCopied from the time when OKX generated the ticker. Milliseconds.
symbolBTC-USDTdata[].instIdCopied.
price_change279.1data[].lastdata[].open24hCalculated: last − open24h, as an exact decimal.
price_change_percent0.32685441data[].lastdata[].open24hCalculated: (last − open24h) / open24h × 100, rounded half-even to 8 decimal places. Percent.
weighted_average_pricenull—Null. OKX does not send a weighted average price.
last_price85668.8data[].lastCopied.
last_quantity0.00047965data[].lastSzCopied. Base asset units.
open_price85389.7data[].open24hCopied. The open price of the last 24 hours.
high_price86994.3data[].high24hCopied.
low_price84979.5data[].low24hCopied.
base_asset_volume6475.49027556data[].vol24hCopied from vol24h. For spot, OKX gives this value in the base asset.
quote_asset_volume557320377.998248583data[].volCcy24hCopied from volCcy24h. For spot, OKX gives this value in the quote asset.
statistics_open_timenull—Null. OKX does not send the limits of the statistics window.
statistics_close_timenull—Null. OKX does not send the limits of the statistics window.
first_trade_idnull—Null. OKX does not send trade IDs in tickers.
last_trade_idnull—Null. OKX does not send trade IDs in tickers.
total_tradesnull—Null. OKX does not send a trade count.

Notes

  • We do not publish the best bid and ask (bidPx, bidSz, askPx, askSz) or the day open prices sodUtc0 and sodUtc8.

For the column types and descriptions, refer to the Ticker schema.

Not published

  • Mark Price: We do not collect this data type for OKX spot. Spot markets have no funding rate.
  • Open Interest: Spot markets have no open interest.
  • Liquidations: We collect liquidations for OKX perpetual swaps only.

If you cannot find the information that you need, tell us. We also help with integrations.

Contact support