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

# Gemini Spot historical trade data

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

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

* **Full history in one place.** Gemini's REST trades endpoint, which our volume check uses to add missing trades, returns at most 500 trades per request and is limited to seven calendar days of data ([Gemini docs](https://developer.gemini.com/trading/rest-api/market-data/list-trades)). Koinju provides it as one continuous history since 2023-07-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, Gemini included, so the same query works on all of them.
* **Checked against Gemini's own data.** Every day, each market's volume is compared with Gemini's own daily candle and any missing trades are added.
* **Faithful to Gemini.** Gemini's own trade IDs and trade times, with prices and quantities exactly as Gemini publishes them.

## At a glance

| Property              | Value                                                         |
| --------------------- | ------------------------------------------------------------- |
| Exchange ID           | `gemini`                                                      |
| Historical data since | 2023-07-01                                                    |
| Data types            | Public trades, OHLCV                                          |
| Collected from        | Gemini's real-time WebSocket, trade stream (`<symbol>@trade`) |
| Volume check          | Every day, against Gemini's UTC daily candles                 |

## How we collect Gemini trades

* **Every trade execution.** We subscribe to Gemini's [trade stream](https://developer.gemini.com/websocket/streams#trade-stream) (`<symbol>@trade`) for every Spot market Gemini lists for trading. Gemini streams trade executions in real time, and each row keeps Gemini'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.
* **Gemini's timestamps.** A trade's `timestamp` is the trade time reported by Gemini, not the time we received it.
* **Exact values.** Prices and quantities are stored exactly as Gemini publishes them, as high-precision decimals with no rounding.

## From Gemini's message to your data

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

| Gemini field | Koinju column | Notes                                                                               |
| ------------ | ------------- | ----------------------------------------------------------------------------------- |
| `s`          | `market`      | Koinju's universal symbol, for example `BTC-USD`                                    |
| `t`          | `trade_id`    | Gemini's own trade ID                                                               |
| `p`          | `price`       | Exact decimal, no rounding                                                          |
| `q`          | `quantity`    | Exact decimal, as Gemini publishes it                                               |
| `m`          | `side`        | `sell` when `m` (the buyer is the maker) is true, otherwise `buy`: the taker's side |
| `E`          | `timestamp`   | Gemini's event time for the trade, in nanoseconds                                   |

## How we verify that no Gemini trades are missed

### Volume check against Gemini's own candles

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

## Gemini-specific details

* **UTC daily candles.** Gemini's daily candles (`1day`) 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 volume, the last of the six values Gemini returns for each candle ([Gemini docs](https://developer.gemini.com/trading/rest-api/market-data/list-candles)), with the sum of the trade quantities we hold for that day.
* **Taker side from the maker flag.** Gemini's trade stream carries `m`, whether the buyer was the maker, instead of a side ([Gemini docs](https://developer.gemini.com/websocket/streams#trade-stream)). We store the taker's side: `sell` when the buyer was the maker, `buy` otherwise, the same meaning as `type` in Gemini's REST trades ([Gemini docs](https://developer.gemini.com/trading/rest-api/market-data/list-trades)).

## Access Gemini data

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

## FAQ

**How does Koinju set the side of a Gemini trade?**

Gemini's trade stream publishes `m`, whether the buyer was the maker. We store the taker's side: `sell` when the buyer was the maker, `buy` otherwise.

**Which timestamp does Koinju store?**

The trade time reported by Gemini.

**Which Gemini Spot markets are included?**

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