> For the complete documentation index, see [llms.txt](https://docs.koinju.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.koinju.io/exchanges/binance.md).

# Binance Spot historical trade data

Binance Spot historical trade data since 2017-07-14, available through SQL or REST in one unified schema and checked every day against Binance's own data.

Koinju provides Binance Spot trades and OHLCV candles for all markets since **2017-07-14**, under the exchange ID `binance`. This page explains what that gives you compared with Binance's own API, how we collect the data, and how we verify that no trades are missed.

{% hint style="info" %}
How far back you can query depends on your plan: see [Pricing](/pricing.md). Every exchange and its start date is listed on [Coverage](/data/coverage.md).
{% endhint %}

## Why use Koinju for Binance data

* **Full history in one place.** Binance serves Spot trade history through a REST API that returns up to 1,000 trades per call under request-weight limits ([Binance docs](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#historical-trades)), and as daily and monthly download files ([Binance public data](https://data.binance.vision/)). Koinju provides it as one continuous history since 2017-07-14, aligned to UTC days and queryable for any period through SQL or REST.
* **One schema across exchanges.** Unified symbols and columns across every exchange we cover, Binance included, so the same query works on all of them.
* **Checked against Binance's own data.** Every day, each market's volume is compared with Binance's own daily candle and any missing trades are added.
* **Faithful to Binance.** Binance's own trade IDs and trade times, with prices and quantities exactly as Binance publishes them.

## At a glance

| Property              | Value                                                           |
| --------------------- | --------------------------------------------------------------- |
| Exchange ID           | `binance`                                                       |
| Historical data since | 2017-07-14                                                      |
| Data types            | Public trades, OHLCV                                            |
| Collected from        | Binance's real-time WebSocket, Trade Streams (`<symbol>@trade`) |
| Volume check          | Every day, against Binance's UTC daily candles                  |

## How we collect Binance trades

* **Every trade, individually.** We subscribe to Binance's [Trade Streams](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams#trade) (`<symbol>@trade`) for every listed Binance Spot market. Binance publishes them as raw trade information in which each trade has a unique buyer and seller, and each row keeps Binance's own trade ID.
* **New listings picked up automatically.** The market list is refreshed every minute, and new markets are subscribed without a restart.
* **Active redundancy.** Every market is collected twice, by two collectors running in parallel. If one connection drops, it reconnects and resubscribes automatically while the other keeps collecting trades. Both copies of a trade share one key (exchange, market and trade ID), so the second copy is dropped before storage, and anything missed is recovered by the checks below.
* **Binance's timestamps.** A trade's `timestamp` is the trade time reported by Binance, not the time we received it.
* **Exact values.** Prices and quantities are stored exactly as Binance publishes them, as high-precision decimals with no rounding.

## From Binance's message to your data

Each trade Binance publishes is stored as one row, with Binance's fields mapped to the same columns used for every exchange:

| Binance field | Koinju column | Notes                                                                                      |
| ------------- | ------------- | ------------------------------------------------------------------------------------------ |
| `s`           | `market`      | Koinju's universal symbol, for example `BTC-USDT`                                          |
| `t`           | `trade_id`    | Binance's own trade ID                                                                     |
| `p`           | `price`       | Exact decimal, no rounding                                                                 |
| `q`           | `quantity`    | Exact decimal, as Binance publishes it                                                     |
| `m`           | `side`        | `buy` when Binance's `m` flag ("Is the buyer the market maker?") is true, otherwise `sell` |
| `T`           | `timestamp`   | Binance's trade time, in milliseconds                                                      |

## How we verify that no Binance trades are missed

### Volume check against Binance's own candles

The reference is Binance's own daily candle for each UTC day. A daily candle is only final once the day has closed, so each day is checked the morning after, against Binance's final figures for that day. The daily rhythm follows the reference data rather than an arbitrary time window.

1. **Compare.** Each market's volume for the UTC day is compared with Binance's daily candle. Markets where our volume is lower than Binance's go to step 2.
2. **Add.** For those markets, the comparison is repeated hour by hour. The trades of the hours that differ are fetched from Binance's REST API, and only trades we do not already hold are added.
3. **Re-check.** The whole comparison runs again on the updated data, and any difference that remains is flagged for review.

A day is marked as checked only after all three steps complete. If any step fails, the day stays open and is retried on the next run.

## Binance-specific details

* **UTC daily candles.** Binance's Spot daily candles (`interval=1d`) are aligned to UTC by default ([Binance docs](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#klines)), the same day boundaries as our daily total.
* **The exact figure compared.** The volume check compares the daily candle's `Volume` field with the sum of the trade quantities we hold for that day.

## Access Binance data

* [Public trades](/data/public-trades.md): every trade, through SQL (`api.trade`) or REST, with `exchange = 'binance'`.
* [OHLCV](/data/ohlcv.md): candles for every market.
* [Market list](/data/market-list.md): all `binance` markets and their symbols.
* [How to connect](/how-to-connect.md): SQL, REST and client setup.

## FAQ

**Which timestamp does Koinju store?**

The trade time reported by Binance.

**Which Binance Spot markets are included?**

Every Spot market Binance lists as trading. The market list is refreshed every minute, so a new listing is subscribed within a minute of appearing in Binance's market list.
