Skip to main content
This endpoint is only available to Growth and Enterprise plans.

Endpoint Details

  • URL: wss://pm-api-prod-eu.mobula.io
  • Event Type: pm-market-trade

Subscription Format

Subscribe to real-time trade events for a prediction market:
{
  "event": "pm-market-trade",
  "data": {
    "platform": "polymarket",
    "marketId": "0x1234...",
    "authorization": "YOUR-API-KEY"
  }
}

Parameters

platform
string
required
Platform name (e.g., polymarket).
marketId
string
required
The platform-specific market identifier.
authorization
string
required
Mobula API key. Also accepts apiKey as alias.
subscriptionId
string
Custom subscription ID for tracking. Auto-generated if not provided.

Subscription Confirmation

After subscribing, you’ll receive a confirmation message:
{
  "event": "subscribed",
  "type": "pm-market-trade",
  "subscriptionId": "abc-456",
  "platform": "polymarket",
  "marketId": "0x1234..."
}

Real-Time Updates

Trade events are pushed as they occur on the CLOB. Each message is a flat object with all fields at the top level:
{
  "event": "pm-market-trade",
  "subscriptionId": "abc-456",
  "platform": "polymarket",
  "marketId": "0x1234...",
  "id": "trade-001",
  "outcomeId": "71321...",
  "type": "buy",
  "priceUSD": 0.65,
  "sizeToken": 500,
  "amountUSD": 325,
  "date": 1709913600000
}

Response Field Definitions

FieldTypeDescription
eventstringAlways pm-market-trade for trade events
subscriptionIdstringYour subscription tracking ID
platformstringPlatform name
marketIdstringMarket identifier
idstringUnique trade identifier
outcomeIdstringOutcome token ID that was traded
typestringTrade type: buy or sell
priceUSDnumberExecution price (0 to 1)
sizeTokennumberTrade size in outcome tokens
amountUSDnumberTrade value in USD
datenumberTrade timestamp in milliseconds

Unsubscribe

To stop receiving updates, send:
{
  "event": "unsubscribe",
  "data": {
    "subscriptionId": "abc-456"
  }
}

Integration Example

const ws = new WebSocket('wss://pm-api-prod-eu.mobula.io');

ws.onopen = () => {
  ws.send(JSON.stringify({
    event: 'pm-market-trade',
    data: {
      platform: 'polymarket',
      marketId: '0x1234...',
      authorization: 'YOUR-API-KEY'
    }
  }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);

  if (msg.event === 'subscribed' && msg.type === 'pm-market-trade') {
    console.log('Subscribed:', msg.subscriptionId);
  }

  if (msg.event === 'pm-market-trade') {
    const { id, outcomeId, type, priceUSD, sizeToken, amountUSD } = msg;
    console.log(`${type} ${sizeToken} @ ${priceUSD} ($${amountUSD}) [${id}]`);
  }
};

Ping / Pong Keepalive

Application-level keepalive: Send { "event": "ping" } and receive { "event": "pong" }. Use this when you need explicit control over keepalive timing.
// Send
{ "event": "ping" }

// Receive
{ "event": "pong" }
The server also sends periodic WebSocket protocol-level ping frames. Most WebSocket libraries handle these automatically. If no response is received within 30 seconds, the server closes the connection.
Requires an active API key with Growth or Enterprise plan. See Authentication for details.