Skip to content

Trade Updates

Receive real-time public trade notifications as they occur on the exchange.

Endpoint

Public subscriptions (candles, marketPrices, orderbook, trades):

wss://papi.synthetix.io/v1/ws/info

Private subscriptions (subAccountUpdates - requires authentication):

wss://papi.synthetix.io/v1/ws/trade

Overview

The trades subscription provides a real-time stream of trades as they are executed. Each message contains details about a single trade including price, quantity, side, and timing information.

Subscription Request

Subscribe to a Specific Symbol

{
  "id": "sub-1",
  "method": "subscribe",
  "params": {
    "type": "trades",
    "symbol": "BTC-USDT"
  }
}

Subscribe to All Symbols

{
  "id": "sub-all",
  "method": "subscribe",
  "params": {
    "type": "trades",
    "symbol": "ALL"
  }
}

Alternatively, omit the symbol parameter to subscribe to all symbols (defaults to "ALL"):

{
  "id": "sub-all",
  "method": "subscribe",
  "params": {
    "type": "trades"
  }
}

Request Parameters

ParameterTypeRequiredDescription
idstringYesClient-generated unique request identifier
methodstringYesMust be "subscribe"
params.typestringYesMust be "trades"
params.symbolstringNoTrading pair symbol (e.g., "BTC-USDT") or "ALL" for all symbols. Defaults to "ALL" if omitted

Unsubscription Request

{
  "id": "unsub-1",
  "method": "unsubscribe",
  "params": {
    "type": "trades",
    "symbol": "BTC-USDT"
  }
}

The type and symbol must match the original subscription request.

Trade Notification Messages

Message Format

{
  "channel": "trade",
  "data": {
    "tradeId": "12345",
    "symbol": "BTC-USDT",
    "side": "buy",
    "price": "50125.50",
    "quantity": "0.15",
    "timestamp": "2025-01-03T12:34:56.789Z",
    "isMaker": false
  },
  "timestamp": 1735907696789
}

Message Fields

FieldTypeDescription
tradeIdstringUnique trade identifier
symbolstringTrading pair symbol (e.g., "BTC-USDT")
sidestringTaker side of the trade: "buy" or "sell"
pricestringExecution price
quantitystringTrade quantity
timestampstringTime of trade execution (RFC3339 format)
isMakerbooleanWhether the reported side was the maker

Implementation Example

const ws = new WebSocket('wss://papi.synthetix.io/v1/ws/info');
 
ws.onopen = () => {
  ws.send(JSON.stringify({
    id: 'sub-1',
    method: 'subscribe',
    params: {
      type: 'trades',
      symbol: 'BTC-USDT'
    }
  }));
};
 
ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
 
  if (message.channel === 'trade') {
    const { tradeId, symbol, side, price, quantity, timestamp } = message.data;
    console.log(`[${timestamp}] ${symbol} ${side} ${quantity} @ ${price} (trade ${tradeId})`);
  }
};

Use Cases

Trading Interfaces

  • Trade Feed: Display a live trade ticker showing recent executions
  • Time & Sales: Build a time-and-sales panel with trade-by-trade data
  • Trade Alerts: Trigger notifications for large trades

Market Analysis

  • Volume Tracking: Aggregate trade quantities over time windows
  • Buy/Sell Pressure: Monitor the ratio of buy vs sell trades
  • Price Impact: Observe how individual trades move the market

Data Feeds

  • Trade History: Build a local trade history database
  • VWAP Calculation: Compute volume-weighted average price in real time
  • Tick Data: Capture every trade for backtesting or analytics

Implementation Notes

  • Public Data: No authentication required — connects to the info WebSocket endpoint
  • Side: The side field represents the taker side of the trade
  • Default Symbol: Omitting symbol defaults to "ALL", streaming trades for every market
  • Message Frequency: High-volume markets may produce a large number of messages — consider filtering by symbol if you only need specific pairs

Error Handling

Subscription Errors

{
  "id": "sub-1",
  "status": 400,
  "result": null,
  "error": {
    "code": 400,
    "message": "Invalid symbol: XYZ-USDT not supported"
  }
}

Common Issues

ErrorDescriptionSolution
Invalid symbolSymbol not availableCheck supported trading pairs via Get Markets
Subscription failedToo many active subscriptionsReduce the number of concurrent subscriptions
Connection timeoutWebSocket disconnectedImplement reconnection logic with exponential backoff

Related Endpoints