Get Open Interest (WebSocket)
Retrieve open interest data for all trading markets through the WebSocket connection. Open interest represents the total number of outstanding derivative contracts that have not been settled.
Endpoint
ws.send() wss://api.synthetix.io/v1/ws/infoRequest
Request Format
{
"id": "oi-1",
"method": "post",
"params": {
"action": "getOpenInterest"
}
}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 "getOpenInterest" |
Response
Success Response
{
"id": "oi-1",
"status": 200,
"result": {
"response": [
{
"symbol": "BTC-USDT",
"openInterest": "1250.50",
"longOpenInterest": "750.25",
"shortOpenInterest": "500.25",
"timestamp": 1704067200000
},
{
"symbol": "ETH-USDT",
"openInterest": "8500.75",
"longOpenInterest": "4800.50",
"shortOpenInterest": "3700.25",
"timestamp": 1704067200000
},
{
"symbol": "SOL-USDT",
"openInterest": "45000.00",
"longOpenInterest": "25000.00",
"shortOpenInterest": "20000.00",
"timestamp": 1704067200000
}
],
"status": "success"
}
}Open Interest Object
| Field | Type | Description |
|---|---|---|
symbol | string | Trading pair symbol (e.g., "BTC-USDT") |
openInterest | string | Total open interest in base asset |
longOpenInterest | string | Long positions open interest in base asset |
shortOpenInterest | string | Short positions open interest in base asset |
timestamp | integer | Unix milliseconds timestamp when open interest was last updated |
Error Response
{
"id": "oi-1",
"status": 500,
"result": null,
"error": {
"code": 500,
"message": "Failed to retrieve open interest data"
}
}WebSocket Connection Example
const ws = new WebSocket('wss://papi.synthetix.io/v1/ws/info');
ws.onopen = () => {
// Request open interest for all markets
ws.send(JSON.stringify({
id: 'oi-1',
method: 'post',
params: {
action: 'getOpenInterest'
}
}));
};
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
if (response.id === 'oi-1' && response.status === 200) {
const openInterestData = response.result.response;
console.log('Open Interest Data:', openInterestData);
// Process open interest
openInterestData.forEach(market => {
console.log(`${market.symbol}:`);
console.log(` Total OI: ${market.openInterest}`);
console.log(` Long: ${market.longOpenInterest}`);
console.log(` Short: ${market.shortOpenInterest}`);
});
}
};Implementation Notes
- Public Data: No authentication required for this endpoint
- All Markets: Returns open interest for all available markets in a single request
- No Filtering: Cannot filter by symbol - all markets are always returned
- Precision: Values are returned as decimal strings to preserve precision
- Real-time Data: Open interest updates as positions are opened/closed
- Long/Short Split: Provides breakdown of long vs short open interest
Use Cases
Market Analysis
- Monitor market sentiment through long/short ratio
- Identify overcrowded trades
- Track market liquidity
- Analyze position imbalances
Risk Management
- Assess market exposure
- Monitor systemic risk
- Track position concentration
- Evaluate market capacity
Trading Strategy
- Contrarian indicators from extreme long/short ratios
- Liquidity assessment for large orders
- Market depth analysis
- Position sizing based on open interest
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)
- Efficient: Minimal payload for quick data retrieval
Understanding Open Interest
Key Metrics
| Metric | Description |
|---|---|
| Total Open Interest | Sum of all outstanding long and short positions |
| Long Open Interest | Total size of all long positions |
| Short Open Interest | Total size of all short positions |
| Long/Short Ratio | Ratio of long to short positions (sentiment indicator) |
Interpretation
- Rising OI + Rising Price: Strong bullish trend (new longs entering)
- Rising OI + Falling Price: Strong bearish trend (new shorts entering)
- Falling OI + Rising Price: Short covering rally (weak bullish)
- Falling OI + Falling Price: Long liquidations (weak bearish)
Validation Rules
- No authentication required (public Info WebSocket)
- No parameters required beyond the action
- Returns all available markets
Related Endpoints
- Get Markets - Market configuration
- Market Price Updates - Real-time price data
- REST Alternative - HTTP request for open interest