Skip to content

Market Price Updates

Get live mark prices, index prices, and funding rates for all markets.

Endpoint

ws.send() wss://api.synthetix.io/v1/ws/subscriptions

Subscription Request

Subscribe to Market Price Updates

{
  "id": "sub-1",
  "method": "subscribe",
  "params": {
    "type": "marketPrices",
    "symbol": "BTC-USDT"
  }
}

Subscribe to All Markets

{
  "id": "sub-all",
  "method": "subscribe",
  "params": {
    "type": "marketPrices",
    "symbol": "ALL"
  }
}

Alternatively, omit the symbol parameter to subscribe to all markets (defaults to "ALL"):

{
  "id": "sub-all",
  "method": "subscribe",
  "params": {
    "type": "marketPrices"
  }
}

Request Parameters

ParameterTypeRequiredDescription
idstringYesClient-generated unique request identifier
methodstringYesMust be "subscribe"
params.typestringYesMust be "marketPrices"
params.symbolstringNoTrading pair symbol or "ALL" for all markets. Defaults to "ALL" if omitted

Market Price Update Messages

Price Update

{
  "method": "market_price_update",
  "data": {
    "symbol": "BTC-USDT",
    "markPrice": "50125.50",
    "indexPrice": "50123.75",
    "lastPrice": "50130.00",
    "bestBid": "50124.00",
    "bestAsk": "50127.00",
    "volume24h": "45678.25",
    "fundingRate": "0.0001",
    "openInterest": "12500.75",
    "timestamp": 1704067200000,
    // Additional fields may be included:
    "nextFundingTime": 1704096000000,
    "change24h": "2.5",
    "changePercent24h": "5.23",
    "high24h": "51000.00",
    "low24h": "49200.00",
    "vwap24h": "50234.67"
  }
}

Funding Rate Update

{
  "method": "market_price_update",
  "data": {
    "symbol": "ETH-USDT",
    "fundingRate": "0.00015",
    "nextFundingRate": "0.00012",
    "nextFundingTime": 1704096000000,
    "fundingInterval": 28800000,
    "timestamp": 1704067300000
  }
}

Minimal Update

{
  "method": "market_price_update",
  "data": {
    "symbol": "SOL-USDT",
    "markPrice": "125.50",
    "indexPrice": "125.48",
    "lastPrice": "125.55",
    "bestBid": "125.49",
    "bestAsk": "125.51",
    "prevDayPrice": "124.80",
    "volume24h": "8934.50",
    "quoteVolume24h": "1120345.25",
    "fundingRate": "0.00015",
    "openInterest": "234567.50",
    "timestamp": 1704067400000
  }
}

Price Data Fields

Market Price Object

FieldTypeDescription
symbolstringTrading pair symbol (e.g., "BTC-USDT")
markPricestringCurrent mark price used for position valuation and liquidation
indexPricestringReference price from external sources (spot exchanges)
lastPricestringLast traded price
bestBidstringBest bid price from order book
bestAskstringBest ask price from order book
prevDayPricestringMarket price 24 hours ago
volume24hstring24-hour trading volume in base asset
fundingRatestring or objectCurrent funding rate as string (e.g., "0.0001"), or empty object {} when unavailable
openIntereststringTotal open interest in base asset
timestampintegerUnix timestamp in milliseconds when data was last updated

Additional Fields in WebSocket Updates

WebSocket price updates may include extended market statistics beyond the standard fields:

FieldTypeDescription
nextFundingTimeintegerNext funding timestamp in milliseconds
change24hstring24-hour price change (absolute)
changePercent24hstring24-hour price change (percentage)
high24hstring24-hour high price
low24hstring24-hour low price
vwap24hstring24-hour volume-weighted average price
quoteVolume24hstring24-hour quote asset volume
trades24hintegerNumber of trades in 24 hours
nextFundingRatestringPredicted next funding rate
fundingIntervalintegerFunding interval in milliseconds
spreadstringCurrent bid-ask spread
spreadPercentstringSpread as percentage of mid price

Note: WebSocket updates combine price, funding, and market statistics in a single message for efficiency. Not all fields are present in every update - partial updates focus on changed data.

Implementation Example

// Subscribe to market price updates
const subscription = {
  id: "sub-1",
  method: "subscribe",
  params: {
    type: "marketPrices",
    symbol: "BTC-USDT"
  }
};
 
ws.send(JSON.stringify(subscription));
 
// Handle market price update messages
ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
 
  if (message.method === "market_price_update") {
    const { symbol, markPrice, fundingRate, changePercent24h } = message.data;
    console.log(`${symbol}: ${markPrice} (${changePercent24h}%) FR: ${fundingRate}`);
 
    // Update UI with new price data
    updatePriceDisplay(message.data);
  }
};
 
function updatePriceDisplay(priceData) {
  const {
    symbol,
    markPrice,
    bestBid,
    bestAsk,
    changePercent24h,
    volume24h,
    fundingRate
  } = priceData;
 
  // Update price ticker
  document.getElementById(`price-${symbol}`).textContent = `${markPrice}`;
  document.getElementById(`change-${symbol}`).textContent = `${changePercent24h}%`;
  document.getElementById(`volume-${symbol}`).textContent = volume24h;
  document.getElementById(`funding-${symbol}`).textContent = `${fundingRate}%`;
 
  // Update bid/ask spread
  const spread = (parseFloat(bestAsk) - parseFloat(bestBid)).toFixed(2);
  document.getElementById(`spread-${symbol}`).textContent = `${spread}`;
}

Multiple Markets

Subscribe to all markets or specific sets of markets:

// Subscribe to all markets
const allMarketsSubscription = {
  id: "sub-all",
  method: "subscribe",
  params: {
    type: "marketPrices",
    symbol: "ALL"
  }
};
 
ws.send(JSON.stringify(allMarketsSubscription));
 
// Handle updates for multiple markets
const marketPrices = new Map();
 
ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
 
  if (message.method === "market_price_update") {
    const { symbol } = message.data;
 
    // Store latest price data
    marketPrices.set(symbol, message.data);
 
    // Update specific market display
    updateMarketRow(symbol, message.data);
  }
};
 
function updateMarketRow(symbol, data) {
  const row = document.getElementById(`market-${symbol}`);
  if (row) {
    row.querySelector('.price').textContent = `${data.markPrice}`;
    row.querySelector('.change').textContent = `${data.changePercent24h}%`;
    row.querySelector('.volume').textContent = data.volume24h;
 
    // Update row styling based on price change
    const changePercent = parseFloat(data.changePercent24h);
    row.className = changePercent >= 0 ? 'positive' : 'negative';
  }
}

Price Alert System

Implement price alerts using market price updates:

class PriceAlertManager {
  constructor() {
    this.alerts = new Map(); // symbol -> array of alerts
  }
 
  addAlert(symbol, targetPrice, direction, callback) {
    if (!this.alerts.has(symbol)) {
      this.alerts.set(symbol, []);
    }
 
    this.alerts.get(symbol).push({
      targetPrice,
      direction, // 'above' or 'below'
      callback,
      id: Date.now()
    });
  }
 
  checkAlerts(symbol, currentPrice) {
    const alerts = this.alerts.get(symbol);
    if (!alerts) return;
 
    const triggeredAlerts = [];
    const remainingAlerts = [];
 
    alerts.forEach(alert => {
      const price = parseFloat(currentPrice);
      const target = parseFloat(alert.targetPrice);
 
      const triggered =
        (alert.direction === 'above' && price >= target) ||
        (alert.direction === 'below' && price <= target);
 
      if (triggered) {
        triggeredAlerts.push(alert);
        alert.callback(symbol, price, alert);
      } else {
        remainingAlerts.push(alert);
      }
    });
 
    // Remove triggered alerts
    this.alerts.set(symbol, remainingAlerts);
  }
}
 
const alertManager = new PriceAlertManager();
 
// Add price alert
alertManager.addAlert('BTC-USDT', '52000.00', 'above', (symbol, price, alert) => {
  console.log(`🚨 ALERT: ${symbol} reached ${price} (target: ${alert.targetPrice})`);
  showNotification(`${symbol} price alert triggered at ${price}`);
});
 
// Check alerts on price updates
ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
 
  if (message.method === "market_price_update") {
    const { symbol, markPrice } = message.data;
    alertManager.checkAlerts(symbol, markPrice);
  }
};

Use Cases

Trading Interfaces

  • Price Tickers: Display real-time prices across all markets
  • Market Overview: Show 24-hour statistics and market performance
  • Spread Monitoring: Track bid-ask spreads for execution quality

Risk Management

  • Mark Price Monitoring: Track mark prices for margin calculations
  • Funding Alerts: Monitor funding rates for cost management
  • Price Alerts: Set up automated price notifications

Market Analysis

  • Volatility Tracking: Monitor price changes and volatility
  • Volume Analysis: Track trading activity across markets
  • Correlation Analysis: Compare price movements between markets

Implementation Notes

  • Update Frequency: Price updates are sent when significant changes occur
  • Data Freshness: All fields include timestamps for data age verification
  • Memory Management: Store only essential price data to avoid memory leaks
  • Error Recovery: Implement reconnection logic to maintain price streams

Error Handling

Subscription Errors

{
  "id": "sub-1",
  "status": 400,
  "result": null,
  "error": {
    "code": 400,
    "message": "Invalid symbol: XYZ-USDT not supported"
  }
}

Common Issues

ErrorDescriptionSolution
Invalid symbolSymbol not availableCheck supported trading pairs
Rate limit exceededToo many subscriptionsLimit concurrent subscriptions
Connection timeoutWebSocket disconnectedImplement reconnection logic

Related Endpoints

  • Get Market Prices - Same comprehensive market data via REST API (including 24h stats)
  • Get Markets - Available trading pairs
  • Orderbook Updates - Depth updates for specific markets
  • Funding Rate Updates - Detailed funding rate information