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.
{"arg": {"channel": "trades-all","instId": "BTC-USDT"},"data": [{"instId": "BTC-USDT",→ symbol"tradeId": "1066842395",→ trade_id"px": "85668.8",→ price"sz": "0.00015743",→ quantity"side": "buy",→ is_buyer_maker"ts": "1791227699299",→ event_time · trade_time"source": "0"}]}
Published row
event_time.true if side is sell (the taker sold, thus the buyer was the maker). false if side is buy.MARKET. This is a placeholder value because OKX does not send an order type.Notes
- The rows come from the
trades-allchannel on the business endpoint. This channel sends one entry for each fill. The publictradeschannel sends one entry for each taker order, fill price and order source. We stopped the use of thetradeschannel in the 2026-09 data-integrity release (refer to the venue notes). - The rows in a file are sorted by
trade_time, then bytrade_id. We publish eachtrade_idonly one time in an hour file. - We do not publish the OKX
sourcefield (0is a normal order,1is 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.
{"arg": {"channel": "books","instId": "BTC-USDT"→ symbol},"action": "snapshot",→ event_type"data": [{"asks": [→ side["85668.8", "0.60167743", "0", "24"],→ side · price · quantity · order_count["85669.8", "0.04202294", "0", "1"],→ side · price · quantity · order_count["85670.7", "0.19024141", "0", "1"]→ side · price · quantity · order_count],"bids": [→ side["85668.7", "0.15616065", "0", "6"],→ side · price · quantity · order_count["85667.8", "0.0000102", "0", "1"],→ side · price · quantity · order_count["85667.4", "0.00001172", "0", "1"]→ side · price · quantity · order_count],"ts": "1791227700007",→ event_time"checksum": 0,"seqId": 82018808615,→ final_update_id"prevSeqId": -1→ last_update_id}]}
Published rows · 6
snapshot when action is snapshot.seqId.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.bid for levels in bids, ask for levels in asks. One row per level.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.
{"arg": {"channel": "books","instId": "BTC-USDT"→ symbol},"action": "update",→ event_type"data": [{"asks": [→ side["85670.3", "0.0000102", "0", "1"],→ side · price · quantity · order_count["85755.7", "0", "0", "0"]→ side · price · quantity · order_count],"bids": [→ side["85659.9", "0.06542374", "0", "3"],→ side · price · quantity · order_count["85657", "0.00448811", "0", "2"]→ side · price · quantity · order_count],"ts": "1791227700107",→ event_time"checksum": 0,"seqId": 82018808663,→ final_update_id"prevSeqId": 82018808615→ prev_final_update_id · last_update_id}]}
Published rows · 4
update when action is update.seqId.prevSeqId. It is equal to the final_update_id of the previous message. If the two values are different, there is a gap.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.bid for levels in bids, ask for levels in asks. One row per level.0 removes the level. Base asset units.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.
{"arg": {"channel": "books","instId": "AUDF-USDT"→ symbol},"action": "snapshot",→ event_type"data": [{"asks": [],"bids": [],"ts": "1791227741701",→ event_time"checksum": 0,"seqId": 696923,→ final_update_id"prevSeqId": -1→ last_update_id}]}
Published row
snapshot when action is snapshot.seqId.prevSeqId (-1 for a snapshot).noop. The message has no levels, thus one marker row keeps its sequence ID.0 on the marker row.0 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.
{"arg": {"channel": "books","instId": "AUDF-USDT"},"action": "update","data": [{"asks": [],"bids": [],"ts": "1791227760001","checksum": 0,"seqId": 696923,"prevSeqId": 696923}]}
Not published
Notes
- OKX stopped the
bookschecksum in 2026. OKX still sends the field, but it is always0and we do not publish it.seqId/prevSeqIdis the only continuity check. An update continues the order book if itsprev_final_update_idis equal to thefinal_update_idof 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
seqIdcan start again at a lower value after maintenance.prevSeqIdis still equal to theseqIdof the previous message. Thus, compare eachprevSeqIdwith the previousseqId. Do not use an increase ofseqIdas 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
openTypecall_auctionorpre_quote). The collector accepts a crossed order book only in that period: from thelistTimeof the instrument to itscontTdSwTime(OKXGET /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_timeis the start of the hour andtransaction_timeis null.final_update_idandlast_update_idare both the lastseqIdthat we applied.
For the column types and descriptions, refer to the Order Book schema.
Ticker
One row per tickers message.
- WebSocket tickers
{"arg": {"channel": "tickers","instId": "BTC-USDT"},"data": [{"instType": "SPOT","instId": "BTC-USDT",→ symbol"last": "85668.8",→ price_change · price_change_percent · last_price"lastSz": "0.00047965",→ last_quantity"askPx": "85668.8","askSz": "0.60167743","bidPx": "85668.7","bidSz": "0.15659044","open24h": "85389.7",→ price_change · price_change_percent · open_price"high24h": "86994.3",→ high_price"low24h": "84979.5",→ low_price"sodUtc0": "86522.4","sodUtc8": "85267.6","volCcy24h": "557320377.998248583",→ quote_asset_volume"vol24h": "6475.49027556",→ base_asset_volume"ts": "1791227699768"→ event_time}]}
Published row
last − open24h, as an exact decimal.last − open24h) / open24h × 100, rounded half-even to 8 decimal places. Percent.vol24h. For spot, OKX gives this value in the base asset.volCcy24h. For spot, OKX gives this value in the quote asset.Notes
- We do not publish the best bid and ask (
bidPx,bidSz,askPx,askSz) or the day open pricessodUtc0andsodUtc8.
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.