> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Prediction Market Details Stream

> Real-time WebSocket stream for prediction market aggregate stats (volume, liquidity, trades)

<Warning>**Alpha** — This endpoint is part of the Prediction Markets API, currently in early access. May change without notice.</Warning>

## Endpoint Details

* **URL**: `wss://pm-api-prod-eu.mobula.io`
* **Event Type**: `pm-market-details`

This stream is the live counterpart to the [`/pm/market/details`](/data/pm/pm-market-details) REST endpoint. Each push carries the current absolute values of the market-level `stats` block — subscribers can merge straight into the snapshot they fetched at page load. Updates are throttled to **1 per second per market** server-side.

## Subscription Format

```json theme={null}
{
  "event": "pm-market-details",
  "data": {
    "platform": "polymarket",
    "marketId": "0x1234..."
  }
}
```

## Parameters

<ParamField body="platform" type="string" required>
  Platform name (e.g., `polymarket`).
</ParamField>

<ParamField body="marketId" type="string" required>
  The platform-specific market identifier (Polymarket condition ID).
</ParamField>

<ParamField body="subscriptionId" type="string">
  Custom subscription ID for tracking. Auto-generated if not provided.
</ParamField>

## Subscription Confirmation

```json theme={null}
{
  "event": "subscribed",
  "type": "pm-market-details",
  "subscriptionId": "abc-789",
  "platform": "polymarket",
  "marketId": "0x1234..."
}
```

## Real-Time Updates

Each tick is a flat object whose mutable fields mirror the `stats` block of the REST response:

```json theme={null}
{
  "event": "pm-market-details",
  "subscriptionId": "abc-789",
  "platform": "polymarket",
  "marketId": "0x1234...",
  "totalVolumeUSD": 30215.42,
  "volume24hUSD": 30215.42,
  "liquidityUSD": 10984.13,
  "tradesCount": 2241,
  "trades24h": 2241,
  "tradesPerMinute": 38,
  "lastTradeAt": 1747569612400,
  "timestamp": 1747569612480
}
```

### Response Field Definitions

| Field             | Type           | Description                                                                                                 |
| ----------------- | -------------- | ----------------------------------------------------------------------------------------------------------- |
| `event`           | string         | Always `pm-market-details`                                                                                  |
| `subscriptionId`  | string         | Your subscription tracking ID                                                                               |
| `platform`        | string         | Platform name                                                                                               |
| `marketId`        | string         | Market identifier                                                                                           |
| `totalVolumeUSD`  | number         | All-time traded volume, in USD                                                                              |
| `volume24hUSD`    | number         | Volume traded over the last 24 hours, in USD                                                                |
| `liquidityUSD`    | number         | Sum of notional book depth across all outcomes (Σ price × size on bids + asks)                              |
| `tradesCount`     | number         | All-time trade count                                                                                        |
| `trades24h`       | number         | Trades in the last 24 hours                                                                                 |
| `tradesPerMinute` | number         | Trade count over the last 60 seconds (momentum indicator)                                                   |
| `lastTradeAt`     | number \| null | Timestamp of the most recent trade (ms epoch), or `null` if no trade observed since the ingress pod started |
| `timestamp`       | number         | Server timestamp when this update was emitted (ms epoch)                                                    |

### Update cadence

* **Triggered on**: every executed trade, every book snapshot
* **Server-side throttle**: at most 1 message per second per market
* **Cold markets**: the first push only happens once the market's REST snapshot is in cache — hit [`/pm/market/details`](/data/pm/pm-market-details) once at subscribe time to warm it instantly, or wait up to a few seconds.

## Unsubscribe

```json theme={null}
{
  "event": "unsubscribe",
  "data": {
    "subscriptionId": "abc-789"
  }
}
```

## Integration Example

```typescript theme={null}
const ws = new WebSocket('wss://pm-api-prod-eu.mobula.io');

// Warm the REST cache so the first WS push fires immediately.
fetch('https://pm-api-prod-eu.mobula.io/api/2/pm/market/details?platform=polymarket&marketId=0x1234...');

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

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

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

  if (msg.event === 'pm-market-details') {
    const { volume24hUSD, liquidityUSD, tradesPerMinute } = msg;
    console.log(`24h vol $${volume24hUSD.toFixed(0)} | liquidity $${liquidityUSD.toFixed(0)} | ${tradesPerMinute} trades/min`);
  }
};
```

## Ping / Pong Keepalive

Send `{ "event": "ping" }` to receive `{ "event": "pong" }`. The server also responds to WebSocket protocol-level pings — most client libraries handle these automatically.
