Skip to content

Get Mid Prices (WebSocket)

Retrieve the current mid prices for all available markets through the WebSocket connection. Mid prices represent the midpoint between the best bid and best ask prices, providing a simple reference price for each market.

Endpoint

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

Request

Request Format

{
  "id": "mids-1",
  "method": "post",
  "params": {
    "action": "getMids"
  }
}

Request Parameters

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

Response

Success Response

{
  "id": "mids-1",
  "status": 200,
  "result": {
    "response": {
      "BTC-USDT": "45025.37500000",
      "ETH-USDT": "2845.12500000",
      "SOL-USDT": "98.75000000",
      "AVAX-USDT": "35.50000000"
    },
    "status": "success"
  }
}

Response Fields

FieldTypeDescription
result.response.{symbol}stringMid price for the specified market symbol as a decimal string
result.statusstringAlways "success" for successful responses

Error Response

{
  "id": "mids-1",
  "status": 500,
  "result": null,
  "error": {
    "code": 500,
    "message": "Could not pull market configuration"
  }
}

WebSocket Connection Example

const ws = new WebSocket('wss://papi.synthetix.io/v1/ws/info');
 
ws.onopen = () => {
  // Request mid prices for all markets
  ws.send(JSON.stringify({
    id: 'mids-1',
    method: 'post',
    params: {
      action: 'getMids'
    }
  }));
};
 
ws.onmessage = (event) => {
  const response = JSON.parse(event.data);
 
  if (response.id === 'mids-1' && response.status === 200) {
    const midPrices = response.result.response;
    console.log('Mid Prices:', midPrices);
    // Process mid prices
    Object.entries(midPrices).forEach(([symbol, price]) => {
      console.log(`${symbol}: ${price}`);
    });
  }
};

Implementation Notes

  • Public Data: No authentication required for this endpoint
  • All Markets: Returns mid prices for all available markets in a single request
  • No Filtering: Cannot filter by symbol - all markets are always returned
  • Mid Price Calculation: Calculated from the latest price feed data
  • Precision: Prices are returned as decimal strings to preserve precision
  • Efficient: Single request returns all market mid prices

Use Cases

Price Monitoring

  • Quick overview of all market prices
  • Price comparison across markets
  • Market snapshot for dashboards

Trading Interfaces

  • Display current market prices
  • Calculate position values
  • Show market overview

Data Feeds

  • Simple price aggregation
  • Price feed for external systems
  • Market status displays

Performance Considerations

  • Low Latency: WebSocket connection provides faster response times than REST
  • Persistent Connection: Reuse the same connection for multiple requests
  • All Markets: Single request returns all markets (no need for multiple calls)
  • Real-time Updates: For continuous updates, use marketPriceUpdates subscription

Comparison with Other Price Endpoints

FeaturegetMidsgetMarketPrices
Data ReturnedMid price onlyMark, index, best bid/ask, mid, and more
MarketsAll marketsCan filter by symbols
Response SizeMinimalComprehensive
Use CaseQuick price referenceDetailed price data

Validation Rules

  • No authentication required (public Info WebSocket)
  • No parameters required beyond the action
  • Returns all available markets

Related Endpoints