Subscribing to the price updates provides real-time data on index, contract, and/or mark prices.
// Subscribe to the index price updates
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.index_price.subscribe",
"params": {
"index": "BTC"
}
}
// Subscribe to the contract last price updates
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.contract_last_price.subscribe",
"params": {
"contract": "BTC-24MAR24"
}
}
// Subscribe to the mark price updates
{
"id": 1,
"jsonrpc": "2.0",
"method": "market.mark_price.subscribe",
"params": {
"contract": "BTC-24MAR24"
}
}
Parameters:
contract
: ID or symbol of the contract.index
: ID or symbol of the index.with_snapshot
: Whether to include the snapshot in the response. It may incur additional API credit spending.from_block_id
: Specifies the block from which to start sending the events. See more information about this in the Managing Data Integrity section.
Snapshots
The snapshots contain the latest price in the block. If multiple updates to the price were made in one block, only the last one will be persisted.
{
"jsonrpc": "2.0",
"method": "market.index_price.snapshot",
"params": {
"index": "BTC",
"data": [
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
},
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
]
}
}
{
"jsonrpc": "2.0",
"method": "market.contract_last_price.snapshot",
"params": {
"contract": "BTC-31MAY24",
"data": [
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
},
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
]
}
}
{
"jsonrpc": "2.0",
"method": "market.mark_price.snapshot",
"params": {
"contract": "BTC-31MAY24",
"data": [
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
},
{
"price": "45677",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
]
}
}
Events
{
"jsonrpc": "2.0",
"method": "market.index_price.event",
"params": {
"index": "BTC",
"data": {
"price": "45678",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
}
}
{
"jsonrpc": "2.0",
"method": "market.contract_last_price.event",
"params": {
"contract": "BTC-31MAY24",
"data": {
"price": "45678",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
}
}
{
"jsonrpc": "2.0",
"method": "market.mark_price.event",
"params": {
"contract": "BTC-31MAY24",
"data": {
"price": "45678",
"block": {
"block_id": 123456,
"block_timestamp": "2024-05-07T10:30:00Z"
}
}
}
}