Subscribing to the candle updates provides real-time data on new candlesticks.
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.candle_updates.subscribe",
"params":
{
"with_snapshot": true,
"index": "BTC",
"price_type": "index",
"period": "1m"
}
}
Parameters:
contract
: ID or symbol of the contract. Required whenprice_type
is 'contract' or 'mark'.index
: ID or symbol of the index. Required whenprice_type
is 'index'.period
: Determines the granularity of the candlesticks. Possible values are: '1m', '5m', '15m', '30m', '1h', '2h', '3h', '4h', '8h', '1d', '5d', '7d', '1M'.price_type
: Type of price that candlesticks are based on. Possible values are: 'contract', 'mark', 'index'.with_snapshot
: Whether to include the snapshot in the response. It may incur additional API credit spending.
Snapshots
The snapshot format is the same as v1/market/indices/{index}/price, v1/market/futures/{contract}/price, v1/market/futures/{contract}/mark-price . Upon subscription, the list of the latest candlesticks are provided:
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.candle_updates.snapshot",
"params": {
"index": "BTC",
"price_type": "index",
"period": "1m",
"data": [
{
"time_open": "2024-05-01T00:00:00Z",
"time_close": "2024-05-01T01:00:00Z",
"price_open": "32500.50",
"price_close": "32600.75",
"price_low": "32480.10",
"price_high": "32650.00",
"volume_contracts": "150.543",
"volume_tokens":10,
"volume_base": "490.545234"
}
]
}
}
Events
The event format is the same as v1/market/indices/{index}/price, v1/market/futures/{contract}/price, v1/market/futures/{contract}/mark-price .
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.candle_updates.event",
"params": {
"index": "BTC",
"price_type": "index",
"period": "1m",
"data": {
"time_open": "2024-05-01T00:00:00Z",
"time_close": "2024-05-01T01:00:00Z",
"price_open": "32500.50",
"price_close": "32600.75",
"price_low": "32480.10",
"price_high": "32650.00",
"volume_contracts": "150.543",
"volume_tokens":10,
"volume_base": "490.545234"
}
}
}