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

# Coinbase Spot historical trade data

Coinbase Spot historical trade data since 2014-12-01, available through SQL or REST in one unified schema and checked by trade ID against Coinbase's own data.

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

* **Full history in one place.** Coinbase's REST API returns trades newest first, in pages of up to 1,000, with no way to request a time range, at up to 10 requests per second ([Coinbase docs](https://docs.cdp.coinbase.com/api-reference/exchange-api/rest-api/products/get-product-trades)). Koinju provides it as one continuous history since 2014-12-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, Coinbase included, so the same query works on all of them.
* **Checked against Coinbase's own data.** Several times a day, Coinbase's trade IDs are checked for gaps, and any missing trades are fetched from Coinbase and added.
* **Faithful to Coinbase.** Coinbase's own trade IDs and trade times, with prices and quantities exactly as Coinbase publishes them.

## At a glance

| Property                | Value                                                            |
| ----------------------- | ---------------------------------------------------------------- |
| Exchange ID             | `coinbase`                                                       |
| Historical data since   | 2014-12-01                                                       |
| Data types              | Public trades, OHLCV                                             |
| Collected from          | Coinbase's real-time WebSocket feed, matches channel (`matches`) |
| Trade-ID sequence check | Several times a day, against Coinbase's trade IDs                |

## How we collect Coinbase trades

* **Every trade, individually.** We subscribe to Coinbase's [matches channel](https://docs.cdp.coinbase.com/exchange/websocket-feed/channels) (`matches`) for every listed Coinbase market. Coinbase describes each `match` as a trade between two orders, and each row keeps Coinbase'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.
* **Coinbase's timestamps.** A trade's `timestamp` is the trade time reported by Coinbase, not the time we received it.
* **Exact values.** Prices and quantities are stored exactly as Coinbase publishes them, as high-precision decimals with no rounding.

## From Coinbase's message to your data

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

| Coinbase field | Koinju column | Notes                                                                  |
| -------------- | ------------- | ---------------------------------------------------------------------- |
| `product_id`   | `market`      | Koinju's universal symbol, for example `BTC-USD`                       |
| `trade_id`     | `trade_id`    | Coinbase's own trade ID                                                |
| `price`        | `price`       | Exact decimal, no rounding                                             |
| `size`         | `quantity`    | Exact decimal, as Coinbase publishes it                                |
| `side`         | `side`        | `buy` or `sell`: the side of the maker order, as Coinbase publishes it |
| `time`         | `timestamp`   | Coinbase's trade time                                                  |

## How we verify that no Coinbase trades are missed

Coinbase notes that messages on its matches channel can be dropped, and recommends tracking the last trade ID to fetch missed trades from its REST API ([Coinbase docs](https://docs.cdp.coinbase.com/exchange/websocket-feed/channels)). Our trade-ID sequence check does this automatically: it finds the missing trade IDs and fetches those trades from Coinbase's REST API.

### Trade-ID sequence check

Coinbase's trade IDs increase by one with each trade in a market, so a jump in the sequence shows exactly which trades are missing. Several times a day, we scan newly collected trades for jumps in trade IDs (gaps) and repeated trade IDs (duplicates).

* **Gaps.** For each gap, the missing trades are requested from Coinbase by trade ID, and each one is added only if its timestamp falls inside the gap's time window.
* **Duplicates.** When a trade ID appears more than once, the extra copies are removed so a single row remains, and the hour's volume is checked again to confirm that only the copies were removed.

## Coinbase-specific details

* **Maker-side `side`.** Coinbase's `side` field is the side of the maker order, the order that was open on the order book ([Coinbase docs](https://docs.cdp.coinbase.com/api-reference/exchange-api/rest-api/products/get-product-trades)). We store it as Coinbase publishes it.

## Access Coinbase data

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

## FAQ

**Why does Koinju check Coinbase trades by trade ID?**

Coinbase notes that messages on its matches channel can be dropped and recommends using trade IDs to fetch missed trades from its REST API. Our trade-ID sequence check does this automatically, several times a day.

**Which timestamp does Koinju store?**

The trade time reported by Coinbase.

**Which Coinbase markets are included?**

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