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/infoRequest
Request Format
{
"id": "market-prices-1",
"method": "post",
"params": {
"action": "getMarketPrices"
}
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Client-generated unique request identifier |
method | string | Yes | Must be "post" |
params | object | Yes | Request parameters wrapper |
params.action | string | Yes | Must 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
| Field | Type | Description |
|---|---|---|
result.response | object | Map of market symbols to their price data |
result.status | string | Always "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
| Field | Type | Description |
|---|---|---|
symbol | string | Trading pair symbol (e.g., "BTC-USDT") |
markPrice | string | Current mark price used for position valuation and liquidation |
indexPrice | string | Reference price from external sources (spot exchanges) |
lastPrice | string | Last traded price |
bestBid | string | Best bid price from order book |
bestAsk | string | Best ask price from order book |
prevDayPrice | string | Market price 24 hours ago |
volume24h | string | 24-hour trading volume in base asset |
quoteVolume24h | string | 24-hour trading volume in quote asset (e.g., USDT) |
fundingRate | string | Funding rate (currently returns "0" - not populated by this endpoint. Use Get Funding Rate for actual funding rates) |
openInterest | string | Total open interest in base asset |
timestamp | integer | Unix 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
| Error | Description |
|---|---|
| Market configuration unavailable | Failed to retrieve market list |
| Mark price unavailable | Failed to retrieve mark price data |
| Index price unavailable | Failed to retrieve index price data |
| Could not get market prices | Internal 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
- Market Price Updates - Real-time streaming of price updates
- Get Markets - Market configuration and trading rules
- Get Mid Prices - Simple mid prices for all markets
- Get Funding Rate - Current funding rates
- Get Open Interest - Open interest data
- REST Alternative - HTTP request for market prices