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

# Market Metrics

> Stream real-time volume, fees, and transaction metrics per market.

<Note>
  **Room ID:** `polymarket_market_metrics` \
  **Endpoint:** `wss://api.struct.to/ws` \
  **Rate:** 0.025 credits per message
</Note>

Stream real-time volume, fees, and transaction metrics for specific markets. Updates are pushed whenever metric values change within the tracked timeframe windows.

## Subscribe

The `condition_ids` filter is required. You may optionally specify `timeframes` to limit which windows you receive. A maximum of 100 filters is allowed per client.

### Filters

| Filter          | Type       | Required | Description                                                                                                                       |
| --------------- | ---------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `condition_ids` | `string[]` | Yes      | Markets to track by condition ID                                                                                                  |
| `timeframes`    | `string[]` | No       | Timeframe windows to receive updates for                                                                                          |
| `subscribe_all` | `boolean`  | No       | Firehose: receive metrics for every market condition. `condition_ids` are ignored when set; the `timeframes` filter still applies |

### Example

```json theme={null}
{
  "type": "join_room",
  "payload": {
    "room_id": "polymarket_market_metrics"
  }
}
```

```json theme={null}
{
  "type": "room_message",
  "payload": {
    "room_id": "polymarket_market_metrics",
    "message": {
      "action": "subscribe",
      "condition_ids": ["0xabc123..."]
    }
  }
}
```

### Response

```json theme={null}
{
  "type": "market_metrics_stream_subscribe_response",
  "room_id": "polymarket_market_metrics",
  "data": {
    "condition_ids": ["0xabc123..."],
    "timeframes": [],
    "rejected": []
  }
}
```

## Events

### `market_metrics_update`

<Info>
  **Volume on Polymarket vs. Struct.** Polymarket's UI reports "volume" as notional (the count of shares or contracts traded), which corresponds to `shares_volume` in Struct payloads. `usd_volume` is the dollar value of those trades. Use `shares_volume` to match figures shown on Polymarket and `usd_volume` for true USD throughput.
</Info>

USD and shares volumes are decimal strings to preserve precision. Builder-attributed fields cover the subset of activity routed through builder-signed orders.

```json theme={null}
{
  "type": "market_metrics_update",
  "room_id": "polymarket_market_metrics",
  "data": {
    "condition_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "timeframe": "1h",
    "timestamp": 1743500000,
    "usd_volume": "125000.50",
    "shares_volume": "192300.00",
    "builder_usd_volume": "31200.00",
    "builder_shares_volume": "48000.00",
    "fees": 250.0,
    "builder_fees": 62.5,
    "txns": 340,
    "builder_txns": 85,
    "unique_traders": 85,
    "unique_builder_traders": 22
  }
}
```
