Skip to content

Get Market Prices (WebSocket)

Retrieve current market prices and 24-hour statistics for all trading pairs through the WebSocket connection. This endpoint provides comprehensive real-time pricing data without requiring authentication.

Endpoint

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

Request

Request Format

{
  "id": "market-prices-1",
  "method": "post",
  "params": {
    "action": "getMarketPrices"
  }
}

Request Parameters

ParameterTypeRequiredDescription
idstringYesClient-generated unique request identifier
methodstringYesMust be "post"
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getMarketPrices"

Response

Success Response

{
  "id": "market-prices-1",
  "status": 200,
  "result": {
    "response": {
      "BTC-USDT": {
        "symbol": "BTC-USDT",
        "markPrice": "45025.37500000",
        "indexPrice": "45025.50000000",
        "lastPrice": "45025.00000000",
        "bestBid": "45020.00000000",
        "bestAsk": "45030.00000000",
        "volume24h": "1250.50",
        "quoteVolume24h": "56282500.00",
        "fundingRate": "0.00001250",
        "openInterest": "12500.75",
        "prevDayPrice": "44952.00000000",
        "timestamp": 1704067200000
      },
      "ETH-USDT": {
        "symbol": "ETH-USDT",
        "markPrice": "2998.75000000",
        "indexPrice": "2998.80000000",
        "lastPrice": "2998.75000000",
        "bestBid": "2996.00000000",
        "bestAsk": "3001.50000000",
        "volume24h": "8945.25",
        "quoteVolume24h": "26800000.00",
        "fundingRate": "0.00001250",
        "openInterest": "45678.50",
        "prevDayPrice": "2804.00000000",
        "timestamp": 1704067200000
      }
    },
    "status": "success"
  }
}

Response Fields

FieldTypeDescription
result.responseobjectMap of market symbols to their price data
result.statusstringAlways "success" for successful responses

The response returns an object (map) where keys are market symbols and values are market price data:

  • Object Format: Keys are market symbols (e.g., "BTC-USDT"), enabling O(1) lookups
  • Combined Data: Each value includes real-time prices and rolling 24-hour statistics
  • Symbol Included: Each object contains the symbol field for consistency
  • Fast Access: Direct access to specific market data without iteration

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
quoteVolume24hstring24-hour trading volume in quote asset (e.g., USDT)
fundingRatestringFunding rate (currently returns "0" - not populated by this endpoint. Use Get Funding Rate for actual funding rates)
openIntereststringTotal open interest in base asset
timestampintegerUnix timestamp in milliseconds when the data was last updated

Error Response

{
  "id": "market-prices-1",
  "status": 500,
  "result": null,
  "error": {
    "code": 500,
    "message": "Could not get market prices"
  }
}

WebSocket Connection Example

const ws = new WebSocket('wss://papi.synthetix.io/v1/ws/info');
 
ws.onopen = () => {
  // Request all market prices
  ws.send(JSON.stringify({
    id: 'market-prices-1',
    method: 'post',
    params: {
      action: 'getMarketPrices'
    }
  }));
};
 
ws.onmessage = (event) => {
  const response = JSON.parse(event.data);
 
  if (response.id === 'market-prices-1' && response.status === 200) {
    const markets = response.result.response;
 
    // Access specific market
    const btc = markets['BTC-USDT'];
    console.log(`BTC Mark Price: ${btc.markPrice}`);
    console.log(`BTC 24h Volume: ${btc.volume24h}`);
 
    // Iterate all markets
    Object.values(markets).forEach(market => {
      console.log(`${market.symbol}: ${market.lastPrice}`);
    });
  }
};

Examples

Get All Market Prices

{
  "id": "all-prices",
  "method": "post",
  "params": {
    "action": "getMarketPrices"
  }
}

Processing Response Data

// Access specific market directly by symbol
const btcPrice = response.result.response['BTC-USDT'].markPrice;
 
// Calculate 24h price change
const market = response.result.response['ETH-USDT'];
const priceChange = parseFloat(market.lastPrice) - parseFloat(market.prevDayPrice);
const priceChangePercent = (priceChange / parseFloat(market.prevDayPrice)) * 100;
console.log(`ETH 24h Change: ${priceChangePercent.toFixed(2)}%`);
 
// Find highest volume market
const markets = Object.values(response.result.response);
const highestVolume = markets.reduce((max, m) =>
  parseFloat(m.quoteVolume24h) > parseFloat(max.quoteVolume24h) ? m : max
);
console.log(`Highest Volume: ${highestVolume.symbol}`);

Implementation Notes

  • Public Data: No authentication required for this endpoint
  • All Markets: Returns data for all available trading pairs in a single request
  • Real-time Prices: Mark, index, and last prices updated continuously from price feeds
  • Rolling Statistics: 24-hour volume and price change calculated on a rolling window
  • Object Format: Response uses symbol keys for efficient O(1) lookups

Data Fields Explained

Price Types

Mark Price

The mark price is the current fair value of the perpetual contract used for:

  • Position valuation in portfolios
  • Liquidation price calculations
  • PnL calculations
  • Updated continuously based on trading activity and price feeds

Index Price

The index price is a reference price derived from external spot exchanges:

  • Provides an external price reference independent of Synthetix trading
  • Used as a baseline for mark price calculations
  • Sourced from multiple spot exchanges for accuracy

Prev Day Price

The market (last) price 24 hours ago, used for calculating 24-hour price changes.

Core Metrics

Volume

  • volume24h: Total base asset traded in 24 hours (e.g., BTC amount)
  • quoteVolume24h: Total quote asset traded in 24 hours (e.g., USDT amount)
  • Rolling 24-hour window, continuously updated

Funding Rate

  • fundingRate: Currently returns "0" (not populated by this endpoint)
  • For actual funding rates, use Get Funding Rate

Open Interest

  • openInterest: Total open positions in base asset
  • Key indicator of market activity and liquidity

Use Cases

Trading Dashboards

  • Display real-time prices for all markets
  • Show 24-hour price changes and volume
  • Monitor bid/ask spreads across markets

Market Screening

  • Compare volume and open interest across markets
  • Identify most active trading pairs
  • Track market-wide price movements

Portfolio Valuation

  • Mark-to-market position values using mark price
  • Calculate unrealized PnL
  • Monitor price movements affecting open positions

Risk Monitoring

  • Track price volatility across markets
  • Monitor open interest changes
  • Assess market liquidity via bid/ask spreads

Validation Rules

  • No authentication required (public Info WebSocket)
  • No parameters to validate beyond action name
  • Returns data for all available markets
  • Real-time data from price feeds

Common Errors

ErrorDescription
Market configuration unavailableFailed to retrieve market list
Mark price unavailableFailed to retrieve mark price data
Index price unavailableFailed to retrieve index price data
Could not get market pricesInternal service error

Performance Considerations

  • Low Latency: WebSocket connection provides faster response times than REST
  • Persistent Connection: Reuse the same connection for multiple requests
  • Single Request: Get all market data in one request instead of per-market queries
  • Efficient Updates: For continuous updates, use Market Price Updates subscription

Related Endpoints