> ## 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.

# Price Metrics

> Stream rolling pool price, volume, fee, and activity metrics.

> [!NOTE]
>
> **Room ID:** `price_metrics` \
> **Endpoint:** `wss://staging-api.struct.to/ws`

Live rolling price, volume, fee, and activity metrics for on-chain pools. Each update is one pool, with windows grouped under `data.metrics` for `5m`, `1h`, `6h`, and `24h`. `interval_ms` is `0`: updates push whenever metrics change.

The listed token's current `price` and `market_cap` sit at the top of `data`; each window adds its all-time high (`price_ath`, `market_cap_ath`, ...) and window-open price (`price_historical`, ...). Every price and market cap comes in three units: unsuffixed = token B (counter-token) units, `_usd` = USD, `_native` = the chain's native coin. The current price fields are omitted until the pool has a priced swap.

### Migrations

`pool_ids` subscriptions follow migrations automatically. When a subscribed pool migrates (for example a bonding curve graduating to an AMM pool), your `pool_ids` filter moves to the destination pool and its metrics start arriving. This room sends no migration event: watch the [address room](https://docs.struct.to/websockets/rooms/address.md) (an `address_update` for the destination pool with `migrated_from_pool_id`, dirty kind `pool`) to be notified. Pools that had already migrated when you subscribe are followed immediately: the subscribe response's `pool_ids` holds the destination and `migrations` lists each hop. `tokens` filters need nothing: the token keeps its address.

## Subscribe

Combined `pool_ids` + `tokens` + `protocols` is capped at 500. Empty filters or `subscribe_all: true` receive every update.

### Filters

| Filter | Type | Required | Description |
| - | - | - | - |
| `chain` | `string` | No\* | Chain name: `solana`, `bnb`, `base`, `ethereum`, `robinhood`, `arc` |
| `chain_id` | `integer` | No\* | Chain id: `-1`, `56`, `8453`, `1`, `4663`, `5042` |
| `pool_ids` | `string[]` | No | Pool or pair addresses; followed through migrations |
| `tokens` | `string[]` | No | Token addresses. Matches `token_a` only |
| `protocols` | `string[]` | No | Protocol names |
| `interval_ms` | `integer` | No | Only `0` is supported |
| `subscribe_all` | `boolean` | No | Receive every update. Defaults to true when no filters are set |

Provide either `chain` or `chain_id`. Do not send both.

### Example

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

```json theme={null}
{
  "type": "room_message",
  "payload": {
    "room_id": "price_metrics",
    "message": {
      "action": "subscribe",
      "chain": "solana",
      "pool_ids": [
        "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"
      ]
    }
  }
}
```

## Events

Every `subscribe` and `unsubscribe_all` is answered with `price_metrics_stream_subscribe_response` (keys are always long). Here the subscribed pool had already migrated:

```json theme={null}
{
  "type": "price_metrics_stream_subscribe_response",
  "room_id": "price_metrics",
  "data": {
    "chain": "solana",
    "chain_id": -1,
    "interval_ms": 0,
    "pool_ids": [
      "9h1Yf7uTzK5vf5JEn7vznsAKBDmkQxXS4v53jviDm4pk"
    ],
    "tokens": [],
    "protocols": [],
    "subscribe_all": false,
    "migrations": [
      {
        "chain": "solana",
        "chain_id": -1,
        "old_pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
        "new_pool_id": "9h1Yf7uTzK5vf5JEn7vznsAKBDmkQxXS4v53jviDm4pk",
        "token_address": "TokenMint111111111111111111111111111111111"
      }
    ],
    "rejected": []
  }
}
```

The room emits `price_metrics_update`. Pick **Response (Long)** or **Response (Short)** in the right-hand panel. WebSocket defaults to short. See [long and short field names](https://docs.struct.to/api-reference/response-format.md#long-and-short-field-names).

```json Response (Long) theme={null}
{
  "type": "price_metrics_update",
  "room_id": "price_metrics",
  "interval_ms": 0,
  "data": {
    "pool_id": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
    "token_a": "TokenMint111111111111111111111111111111111",
    "token_b": "So11111111111111111111111111111111111111112",
    "timestamp": 1710000000000,
    "protocol": "pumpfun",
    "price": 0.00012,
    "price_usd": 0.018,
    "price_native": 0.00012,
    "market_cap": 1200,
    "market_cap_usd": 180000,
    "market_cap_native": 1200,
    "metrics": {
      "5m": {
        "market_cap_ath": 1800,
        "market_cap_usd_ath": 270000,
        "market_cap_native_ath": 1800,
        "price_ath": 0.00018,
        "price_usd_ath": 0.027,
        "price_native_ath": 0.00018,
        "price_historical": 0.0001,
        "price_historical_usd": 0.015,
        "price_historical_native": 0.0001,
        "buy_volume_usd": 4200,
        "sell_volume_usd": 3100,
        "buy_volume_native": 28.4,
        "sell_volume_native": 20.9,
        "buys": 18,
        "sells": 12,
        "txns": 30,
        "unique_traders": 21,
        "total_bot_fees_native": 0.012,
        "total_fees_native": 0.0172,
        "total_priority_fees_native": 0.004,
        "total_tip_amount_native": 0.0012
      },
      "1h": {
        "market_cap_ath": 1800,
        "market_cap_usd_ath": 270000,
        "market_cap_native_ath": 1800,
        "price_ath": 0.00018,
        "price_usd_ath": 0.027,
        "price_native_ath": 0.00018,
        "price_historical": 0.0001,
        "price_historical_usd": 0.015,
        "price_historical_native": 0.0001,
        "buy_volume_usd": 4200,
        "sell_volume_usd": 3100,
        "buy_volume_native": 28.4,
        "sell_volume_native": 20.9,
        "buys": 18,
        "sells": 12,
        "txns": 30,
        "unique_traders": 21,
        "total_bot_fees_native": 0.012,
        "total_fees_native": 0.0172,
        "total_priority_fees_native": 0.004,
        "total_tip_amount_native": 0.0012
      },
      "6h": {
        "market_cap_ath": 1800,
        "market_cap_usd_ath": 270000,
        "market_cap_native_ath": 1800,
        "price_ath": 0.00018,
        "price_usd_ath": 0.027,
        "price_native_ath": 0.00018,
        "price_historical": 0.0001,
        "price_historical_usd": 0.015,
        "price_historical_native": 0.0001,
        "buy_volume_usd": 4200,
        "sell_volume_usd": 3100,
        "buy_volume_native": 28.4,
        "sell_volume_native": 20.9,
        "buys": 18,
        "sells": 12,
        "txns": 30,
        "unique_traders": 21,
        "total_bot_fees_native": 0.012,
        "total_fees_native": 0.0172,
        "total_priority_fees_native": 0.004,
        "total_tip_amount_native": 0.0012
      },
      "24h": {
        "market_cap_ath": 1800,
        "market_cap_usd_ath": 270000,
        "market_cap_native_ath": 1800,
        "price_ath": 0.00018,
        "price_usd_ath": 0.027,
        "price_native_ath": 0.00018,
        "price_historical": 0.0001,
        "price_historical_usd": 0.015,
        "price_historical_native": 0.0001,
        "buy_volume_usd": 4200,
        "sell_volume_usd": 3100,
        "buy_volume_native": 28.4,
        "sell_volume_native": 20.9,
        "buys": 18,
        "sells": 12,
        "txns": 30,
        "unique_traders": 21,
        "total_bot_fees_native": 0.012,
        "total_fees_native": 0.0172,
        "total_priority_fees_native": 0.004,
        "total_tip_amount_native": 0.0012
      }
    }
  }
}
```

```jsonc Response (Short) theme={null}
{
  "type": "price_metrics_update",
  "room_id": "price_metrics",
  "interval_ms": 0,
  "data": {
    "p": "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
    "ta": "TokenMint111111111111111111111111111111111",
    "tb": "So11111111111111111111111111111111111111112",
    "ts": 1710000000000,
    "pr": "pumpfun",
    "px": 0.00012,
    "pu": 0.018,
    "pn": 0.00012,
    "mc": 1200,
    "mcu": 180000,
    "mcn": 1200,
    "mx": {
      "5m": {
        "mcat": 1800,
        "mca": 270000,
        "mcan": 1800,
        "pat": 0.00018,
        "pua": 0.027,
        "pan": 0.00018,
        "pht": 0.0001,
        "ph": 0.015,
        "phn": 0.0001,
        "bv": 4200,
        "sv": 3100,
        "bvn": 28.4,
        "svn": 20.9,
        "b": 18,
        "s": 12,
        "t": 30,
        "ut": 21,
        "bf": 0.012,
        "tf": 0.0172,
        "pf": 0.004,
        "tip": 0.0012
      },
      "1h": {
        "mcat": 1800,
        "mca": 270000,
        "mcan": 1800,
        "pat": 0.00018,
        "pua": 0.027,
        "pan": 0.00018,
        "pht": 0.0001,
        "ph": 0.015,
        "phn": 0.0001,
        "bv": 4200,
        "sv": 3100,
        "bvn": 28.4,
        "svn": 20.9,
        "b": 18,
        "s": 12,
        "t": 30,
        "ut": 21,
        "bf": 0.012,
        "tf": 0.0172,
        "pf": 0.004,
        "tip": 0.0012
      },
      "6h": {
        "mcat": 1800,
        "mca": 270000,
        "mcan": 1800,
        "pat": 0.00018,
        "pua": 0.027,
        "pan": 0.00018,
        "pht": 0.0001,
        "ph": 0.015,
        "phn": 0.0001,
        "bv": 4200,
        "sv": 3100,
        "bvn": 28.4,
        "svn": 20.9,
        "b": 18,
        "s": 12,
        "t": 30,
        "ut": 21,
        "bf": 0.012,
        "tf": 0.0172,
        "pf": 0.004,
        "tip": 0.0012
      },
      "24h": {
        "mcat": 1800,
        "mca": 270000,
        "mcan": 1800,
        "pat": 0.00018,
        "pua": 0.027,
        "pan": 0.00018,
        "pht": 0.0001,
        "ph": 0.015,
        "phn": 0.0001,
        "bv": 4200,
        "sv": 3100,
        "bvn": 28.4,
        "svn": 20.9,
        "b": 18,
        "s": 12,
        "t": 30,
        "ut": 21,
        "bf": 0.012,
        "tf": 0.0172,
        "pf": 0.004,
        "tip": 0.0012
      }
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.