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

# Stream Kalshi and Polymarket prices and trades

> Stream Kalshi and Polymarket trades, prices, quotes, books, volume, and resolutions through Solana Tracker Datastream.

Subscribe to `pm:*` rooms for prediction-market updates. Select an exchange, market, or event scope, and use the correct ID for that room. Price and orderbook subscriptions are market-specific.

<Info>
  **Public Beta** — Prediction market rooms use the same Datastream hub as other Solana Tracker streams.\
  Connect to `wss://datastream.solanatracker.io/{apiKey}` with your Data API key.
</Info>

## Connecting

```javascript theme={null}
const ws = new WebSocket("wss://datastream.solanatracker.io/YOUR_API_KEY");

ws.onopen = () => {
  ws.send(JSON.stringify({ type: "join", room: "pm:trades" }));
  ws.send(JSON.stringify({
    type: "join",
    room: "pm:market:polymarket:YOUR_TOKEN_ID:prices"
  }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  if (msg.type === "message") console.log(msg.room, msg.data);
};
```

Join / leave:

```json theme={null}
{ "type": "join", "room": "pm:trades" }
{ "type": "leave", "room": "pm:trades" }
```

## Room types

| Room | Purpose |
| - | - |
| `pm:trades` | Full trade tape (all exchanges) |
| `pm:trades:significant` | Trades with **notional ≥ \$25** |
| `pm:{exchange}:trades` | e.g. `pm:polymarket:trades` |
| `pm:market:{exchange}:{marketId}:trades` | Single-market tape |
| `pm:event:{exchange}:{eventId}:trades` | All markets under one event |
| `pm:market:{exchange}:{tokenId}:prices` | Live top-of-book mid (+ `displayPrice`) |
| `pm:market:{exchange}:{tokenId}:quotes` | Streaming size-aware VWAP ladder |
| `pm:market:{exchange}:{tokenId}:orderbook` | Full book snapshots |
| `pm:event:{exchange}:{eventId}:volume` | Live cumulative USD volume for an event |
| `pm:market:{exchange}:{tokenId}:volume` | Live cumulative USD volume for one outcome |
| `pm:crypto:{asset}` | Chainlink underlying (BTC/ETH/…) — not outcome chance |
| `pm:market_lifecycle` / `pm:resolution` | Lifecycle and resolution fan-out |

Price, quote, and orderbook subscriptions require a market ID. There is no global `pm:prices` room.

`notionalUsd` is `price × quantity` (USD). The significant room uses threshold **\$25**.

Event rooms accept identities included in the payload, such as `eventId`, `eventSlug`, `gammaEventId`, or a Kalshi `eventTicker`.

## Volume example

Crypto 5m windows — join with the **event slug**:

```json theme={null}
{ "type": "join", "room": "pm:event:polymarket:btc-updown-5m-1785347100:volume" }
```

```json theme={null}
{
  "type": "message",
  "room": "pm:event:polymarket:btc-updown-5m-1785347100:volume",
  "data": {
    "type": "volume",
    "channel": "volume",
    "exchange": "polymarket",
    "marketId": "{tokenId}",
    "timestamp": 1785347120123,
    "eventId": "btc-updown-5m-1785347100",
    "volume": 48210.55,
    "marketVolume": 24105.27,
    "delta": 42.5
  }
}
```

Replace the displayed volume with the latest frame. Fields include `volume`, `marketVolume`, `delta`, and `eventId`.

## Quotes vs REST

Join `pm:market:polymarket:{tokenId}:quotes` for a streaming size-aware VWAP ladder. For arbitrary sizes use REST `GET /v1/markets/{id}/quote` on `prediction-market-api.solanatracker.io`.

## Prices vs crypto underlying

| Feed | Room | Meaning |
| - | - | - |
| Outcome chance | `pm:market:polymarket:{tokenId}:prices` | CLOB top-of-book mid |
| Underlying | `pm:crypto:{asset}` / `pm:crypto:{asset}:prices` | Chainlink USD ticks |

## IDs

* Room segments are **lowercase**.
* Polymarket market rooms require decimal **CLOB token IDs** (not `0x` condition ids).
* Kalshi tickers appear uppercase in many REST payloads but **lowercase** in room names.

## API reference

In the **Datastream** nav, Prediction Market rooms are grouped as:

| Group | Rooms |
| - | - |
| Prediction Markets — Trades | `pm:trades`, significant, exchange / market / event trades |
| Prediction Markets — Prices | market prices, quotes, orderbook |
| Prediction Markets — Volume | event and market volume |
| Prediction Markets — Lifecycle | lifecycle and resolution |
| Prediction Markets — Crypto | `pm:crypto:{asset}` |
| Prediction Markets — Feeds | exchange, market, event, type, category, series, status, sport |
