This documentation is archived for reference only. These APIs have been replaced by the new WebSocket API. Start new integrations with the new WebSocket API.
Market Data v2
The initial response will show the existing state of the order books and last 50 trades. Subsequent messages show all executed trades and order book changes.
WebSocket Request
wss://api.gemini.com/v2/marketdata
After connecting, subscribe by sending a message:
| Field Name | Type | Values |
|---|---|---|
type | string | subscribe |
subscriptions | array | |
-- name | string | l2, candles_1m, candles_5m, candles_15m, candles_30m, candles_1h, candles_6h, candles_1d |
-- symbols | array | ["BTCUSD", "ETHBTC", ...] |
Subscription Example
Code
Code
Unsubscribe
Code
Level 2 Data
L2 Update Response
| Field Name | Type | Values |
|---|---|---|
type | string | l2_updates |
symbol | string | BTCUSD, etc. |
changes | array of arrays | [side, price, quantity] |
Trade Response
| Field Name | Type | Values |
|---|---|---|
type | string | trade |
symbol | string | BTCUSD, etc. |
event_id | long | Event ID of the trade |
timestamp | long | Time in milliseconds |
price | string | Price of the trade |
quantity | string | Quantity traded |
side | string | Taker side: buy or sell |
tid | long | Trade ID |
Examples
Initial L2 response:
Code
L2 update:
Code
Candles Data Feed
The Candle Data feed provides periodic updates with OHLCV data for the given timeframe.
Subscribe
| Field Name | Type | Values |
|---|---|---|
type | string | subscribe |
subscriptions | array | |
-- name | string | candles_1m, candles_5m, candles_15m, candles_30m, candles_1h, candles_6h, candles_1d |
-- symbols | array | ["BTCUSD", ...] |
Response
| Field Name | Type | Values |
|---|---|---|
type | string | candles_1m_updates, candles_5m_updates, etc. |
symbol | string | BTCUSD, etc. |
changes | array of arrays | [time, open, high, low, close, volume] |
Code
Code
Mark Price Feed
The mark price feed provides mark price updates for perpetual instruments and select spot pairs.
Subscribe
| Field Name | Type | Values |
|---|---|---|
type | string | subscribe |
subscriptions | array | |
-- name | string | mark_price |
-- symbols | array | ["BTCGUSDPERP", "BTCUSD", ...] |
Response
| Field Name | Type | Values |
|---|---|---|
type | string | mark_price_updates |
symbol | string | BTCGUSDPERP |
changes | array |
Each element of changes:
| Field Name | Type | Values |
|---|---|---|
timestamp | integer | nanoseconds |
mark_price | string | mark price |
spot_index | string | spot index |
Code
Funding Amount Feed
The Funding Amount feed provides funding amount updates for perpetual instruments.
Subscribe
| Field Name | Type | Values |
|---|---|---|
type | string | subscribe |
subscriptions | array | |
-- name | string | funding_amount |
-- symbols | array | ["BTC-GUSD-PERP", ...] |
Response
| Field Name | Type | Values |
|---|---|---|
type | string | funding_amount_updates |
symbol | string | BTCGUSDPERP |
changes | array |
Each element of changes:
| Field Name | Type | Values |
|---|---|---|
timestamp | integer | nanoseconds |
funding_amount | string | funding amount |
funding_date_time | integer | funding date time |
funding_interval_in_minutes | integer | funding interval in minutes |
is_realized | boolean | is realized funding |
Code
Last modified on

