Index Price
index_price Channel
Monitor real-time underlying asset price updates for trading pairs.
Subscribe
| Parameter | Required | Description |
|---|---|---|
pair | Yes | Trading pair (e.g., "BTC_USDC", "ETH_USDC", "ARB_USDC") |
{
"type": "subscribe",
"subscriptions": [
{
"channel": "index_price",
"query": {
"pair": "BTC_USDC"
}
}
]
}Event: index_price
{
"kind": "event",
"type": "index_price",
"timestamp_ms": 1677721600000,
"data": {
"value": 45000.5,
"timestamp": 1677721600000
},
"subscription": {
"channel": "index_price",
"query": {
"pair": "BTC_USDC"
}
}
}| Field | Type | Description |
|---|---|---|
data.value | number | Current index price |
data.timestamp | number | Price timestamp in milliseconds |
Example
import WebSocket from 'ws';
const ws = new WebSocket('wss://staging.kyan.sh/ws');
const API_KEY = 'your-api-key-here';
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'auth', api_key: API_KEY }));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data.toString());
if (message.type === 'auth' && message.success) {
ws.send(JSON.stringify({
type: 'subscribe',
subscriptions: [
{ channel: 'index_price', query: { pair: 'BTC_USDC' } }
]
}));
ws.onmessage = handleMessages;
}
};
function handleMessages(event: WebSocket.MessageEvent) {
const message = JSON.parse(event.data.toString());
if (message.event === 'index_price') {
console.log('New index price:', message.data.value);
}
}Updated about 15 hours ago
