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/infoRequest
Request Format
{
"id": "mids-1",
"method": "post",
"params": {
"action": "getMids"
}
}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 "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
| Field | Type | Description |
|---|---|---|
result.response.{symbol} | string | Mid price for the specified market symbol as a decimal string |
result.status | string | Always "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
marketPriceUpdatessubscription
Comparison with Other Price Endpoints
| Feature | getMids | getMarketPrices |
|---|---|---|
| Data Returned | Mid price only | Mark, index, best bid/ask, mid, and more |
| Markets | All markets | Can filter by symbols |
| Response Size | Minimal | Comprehensive |
| Use Case | Quick price reference | Detailed price data |
Validation Rules
- No authentication required (public Info WebSocket)
- No parameters required beyond the action
- Returns all available markets
Related Endpoints
- Get Market Prices - Comprehensive price data via WebSocket
- Market Price Updates - Real-time price streams
- REST Alternative - HTTP request for mid prices