KKLinePic

OKX tick data · historical trades · Kline candles

Download OKX tick data and historical Klines.

“OKX tick data” can mean two different datasets. Public trade ticks are individual executions across the market. Historical Klines are OHLCV candles aggregated from those trades. This guide shows the correct public endpoint for each job, the response fields, pagination rules, and a clean path to CSV.

If you need only your own fills, do not download the whole market. Use the separate OKX Trading history guide, then place those entry and exit rows over Kline data in KLinePic.

Crypto Kline review chart built from market candles and personal fills
Market candles supply the price path; your private fills supply the B/S markers.

Quick answer: choose the dataset before the endpoint

You needOKX endpointResult
Latest public executionsGET /api/v5/market/tradesRecent trade ticks for one instrument
Older public executionsGET /api/v5/market/history-tradesHistorical trade ticks, documented for the latest three months
Latest OHLCV barsGET /api/v5/market/candlesRecent Kline candles at a chosen interval
Older OHLCV barsGET /api/v5/market/history-candlesHistorical Kline candles, paged backward
Your own entries and exitsOKX Order center → Trading history → DownloadPrivate fill export for personal review

The distinction prevents the most common wrong download. Public ticks answer “what traded on the market?” Your private fill export answers “what did I trade?” Candles answer “what did price do during each interval?” A personal review chart normally needs private fills plus candles; it rarely needs every public trade tick.

Download executed trade ticks

Start with the public history endpoint and an exact OKX instrument id such as BTC-USDT for spot or BTC-USDT-SWAP for a perpetual swap:

curl "https://www.okx.com/api/v5/market/history-trades?instId=BTC-USDT&limit=100"

Each returned trade contains an instrument id, trade id, price, size, side, and timestamp. The timestamp is Unix milliseconds. Convert it to UTC before joining ticks with candles or fills. Preserve the trade id as a string: treating a large identifier as a floating-point number can silently change its value.

For a longer pull, paginate in the direction documented by OKX using the boundary id from the oldest item on the page. API responses often arrive newest first. Continue until the oldest timestamp crosses your requested start time, then deduplicate by instId + tradeId and sort ascending. Stop on an empty page or when the boundary stops changing so a transient response cannot create an infinite loop.

instrument,trade_id,time,price,size,side
BTC-USDT,981234567890,2026-08-20T12:30:14.582Z,114250.1,0.004,buy

Public ticks are useful for microstructure work, execution context, volume-at-price studies, and reconstructing very small bars. They are much larger than candle data. If your analysis uses one-minute or one-hour bars, request candles directly instead of downloading thousands of executions only to aggregate them again.

Download historical OKX Kline candles

The historical candle endpoint returns arrays. Request an instrument and bar size, then walk backward with the pagination cursor:

curl "https://www.okx.com/api/v5/market/history-candles?instId=BTC-USDT&bar=1H&limit=300"

OKX candle rows follow the documented order [ts, open, high, low, close, vol, volCcy, volCcyQuote, confirm]. The first value is Unix milliseconds. The final flag tells you whether the candle is complete. For reproducible backtests and completed review charts, exclude an unfinished last candle or record it explicitly instead of mixing it with closed bars.

Volume meanings vary by instrument type. Keep the original base, currency, and quote-volume fields in your raw archive even if your chart CSV uses only one volume column. That preserves enough information to revisit the calculation later. Do not assume spot volume and derivatives contract volume use the same unit.

symbol,time,open,high,low,close,volume
BTCUSDT,2026-08-20T12:00:00.000Z,113980.2,114420.0,113870.1,114250.1,128.442

KLinePic’s custom market-data schema is symbol,time,open,high,low,close,volume. Normalize BTC-USDT to BTCUSDT, convert time to an explicit UTC ISO value, choose the volume field that matches your analysis, deduplicate by symbol plus timestamp, and sort oldest to newest.

Reliability checklist for a real download job

  1. Pin the instrument type. BTC-USDT spot and BTC-USDT-SWAP perpetual are different markets. Never merge them because their prices look similar.
  2. Use UTC internally. Store the original millisecond timestamp and a derived ISO UTC column. Convert to local time only for display.
  3. Respect rate limits. Page sequentially, use bounded retries with backoff, and resume from the last durable cursor instead of restarting the whole range.
  4. Save raw responses. Write immutable raw pages before transformation. If a schema assumption is wrong, you can rebuild the CSV without calling the API again.
  5. Deduplicate after retries. Overlapping pages are normal in a resumable downloader. Trade ids deduplicate ticks; instrument plus timestamp deduplicates candles.
  6. Validate price order. Every candle must satisfy high ≥ open/close and low ≤ open/close. Reject zero or negative prices and impossible timestamps.
  7. Keep completed bars. Use the confirmation flag when a stable research dataset must not change on the next request.
  8. Record provenance. Store endpoint, parameters, collection time, instrument id, bar interval, and timezone alongside each output file.

From OKX market data to a trade review chart

Market data alone does not know your entry, exit, fee, or position direction. Export your private OKX Trading history separately and map the executed fills to KLinePic’s trade schema: trade_id, symbol, event_type, position_side, time, price, quantity, plus optional fee and note. All fills belonging to one round trip share a trade id.

For common symbols, KLinePic can resolve public Kline data automatically, so the trade CSV may be enough. Upload the custom candle CSV only when the chart must use the exact OKX instrument, bar construction, or historical window you collected. The result places B/S markers over the real price path and calculates holding window, return, max run-up, and max drawdown.

This separation also keeps the files honest: the public dataset describes the market, while the private dataset describes your decisions. It prevents a public buy tick from being mistaken for your own entry and makes each review reproducible.

OKX tick data FAQ

What is OKX tick data?

It is the public stream of individual market executions: instrument, trade id, price, size, side, and millisecond timestamp. It is not your account history.

Can I query it without an API key?

The market trade and candle routes are public. Follow the official rate limits and build retries that slow down instead of hammering the endpoint.

How much historical trade data is available?

OKX documents the historical-trades route for the most recent three months. If you need a durable tick archive, collect it regularly and keep the raw pages.

Should I download ticks or candles?

Use ticks for execution-level or microstructure work. Use candles for ordinary charting and indicator calculations; they are much smaller and already aggregated.

Why does the last candle change?

The newest candle may still be open. Read the confirmation field and exclude incomplete bars when you need a stable historical dataset.

Where are my own OKX fills?

Use Assets → Order center → Trading history → Download. That private export, not public tick data, supplies the entries and exits for your personal review chart.

Related guides