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-price

Subscription Format

Subscribe to real-time price updates for a prediction market:
{
  "event": "pm-market-price",
  "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-price",
  "subscriptionId": "abc-123",
  "platform": "polymarket",
  "marketId": "0x1234..."
}

Real-Time Updates

Price updates are pushed whenever the order book changes. Each message is a flat object with all fields at the top level:
{
  "event": "pm-market-price",
  "subscriptionId": "abc-123",
  "platform": "polymarket",
  "marketId": "0x1234...",
  "outcomeId": "71321...",
  "priceUSD": 0.65,
  "bestBidUSD": 0.64,
  "bestAskUSD": 0.66,
  "spreadUSD": 0.02,
  "timestamp": 1709913600000
}

Response Field Definitions

FieldTypeDescription
eventstringAlways pm-market-price for price updates
subscriptionIdstringYour subscription tracking ID
platformstringPlatform name
marketIdstringMarket identifier
outcomeIdstringOutcome token ID
priceUSDnumberMid price (0 to 1)
bestBidUSDnumberBest bid price
bestAskUSDnumberBest ask price
spreadUSDnumberBid-ask spread
timestampnumberServer timestamp in milliseconds

Unsubscribe

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

Integration Example

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

ws.onopen = () => {
  ws.send(JSON.stringify({
    event: 'pm-market-price',
    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-price') {
    console.log('Subscribed:', msg.subscriptionId);
  }

  if (msg.event === 'pm-market-price') {
    const { outcomeId, priceUSD, bestBidUSD, bestAskUSD, spreadUSD } = msg;
    console.log(`Outcome ${outcomeId}: price=${priceUSD} bid=${bestBidUSD} ask=${bestAskUSD} spread=${spreadUSD}`);
  }
};

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.