> 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/gateio.md).

# Gate.io Spot historical trade data

Gate.io Spot historical trade data since 2021-01-01, available through SQL or REST in one unified schema and checked every day against Gate.io's own data.

Koinju provides Gate.io Spot trades and OHLCV candles for all markets since **2021-01-01**, under the exchange ID `gateio`. This page explains what that gives you compared with Gate.io'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 Gate.io data

* **Full history in one place.** Gate.io's REST trade history API, which our volume check uses to add missing trades, returns up to 1,000 trades per call and by default covers the last 30 days ([Gate.io docs](https://www.gate.com/docs/developers/apiv4/en/)). Koinju provides it as one continuous history since 2021-01-01, 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, Gate.io included, so the same query works on all of them.
* **Checked against Gate.io's own data.** Every day, each market's volume is compared with Gate.io's own daily candle and any missing trades are added.
* **Faithful to Gate.io.** Gate.io's own trade IDs and trade times, with prices and quantities exactly as Gate.io publishes them.

## At a glance

| Property              | Value                                                                       |
| --------------------- | --------------------------------------------------------------------------- |
| Exchange ID           | `gateio`                                                                    |
| Historical data since | 2021-01-01                                                                  |
| Data types            | Public trades, OHLCV                                                        |
| Collected from        | Gate.io's real-time WebSocket API v4, public trades channel (`spot.trades`) |
| Volume check          | Every day, against Gate.io's UTC daily candles                              |

## How we collect Gate.io trades

* **Every trade, individually.** We subscribe to Gate.io's [public trades channel](https://www.gate.com/docs/developers/apiv4/ws/en/#public-trades-channel) (`spot.trades`) for every Gate.io Spot market listed as tradable. Gate.io sends a trade message whenever a trade occurs, and each row keeps Gate.io'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.
* **Gate.io's timestamps.** A trade's `timestamp` is the trade time reported by Gate.io, not the time we received it.
* **Exact values.** Prices and quantities are stored exactly as Gate.io publishes them, as high-precision decimals with no rounding.

## From Gate.io's message to your data

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

| Gate.io field    | Koinju column | Notes                                                      |
| ---------------- | ------------- | ---------------------------------------------------------- |
| `currency_pair`  | `market`      | Koinju's universal symbol, for example `BTC-USDT`          |
| `id`             | `trade_id`    | Gate.io's own trade ID                                     |
| `price`          | `price`       | Exact decimal, no rounding                                 |
| `amount`         | `quantity`    | Exact decimal, as Gate.io publishes it                     |
| `side`           | `side`        | `buy` or `sell`: the taker's side, as Gate.io publishes it |
| `create_time_ms` | `timestamp`   | Gate.io's trade time, in milliseconds                      |

## How we verify that no Gate.io trades are missed

### Volume check against Gate.io's own candles

The reference is Gate.io'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 Gate.io'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 Gate.io's daily candle. Markets where our volume is lower than Gate.io'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 Gate.io'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.

## Gate.io-specific details

* **UTC daily candles.** Gate.io's daily candles (`interval=1d`) start at 00:00 UTC, the same day boundaries as our daily total.
* **The exact figure compared.** The volume check compares the daily candle's trading volume in base currency ([Gate.io docs](https://www.gate.com/docs/developers/apiv4/en/)) with the sum of the trade quantities we hold for that day.

## Access Gate.io data

* [Public trades](/data/public-trades.md): every trade, through SQL (`api.trade`) or REST, with `exchange = 'gateio'`.
* [OHLCV](/data/ohlcv.md): candles for every market.
* [Market list](/data/market-list.md): all `gateio` 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 Gate.io.

**Which Gate.io Spot markets are included?**

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