Skip to main content

Price Feed

WS /v1/ws/prices?token=<jwt>
Streams real-time price updates for subscribed markets. All numeric values are strings.

Subscribe

After connecting, send a subscribe message:
{"action": "subscribe", "markets": ["0xabc123...", "0xdef456..."]}
Server confirms:
{"type": "subscribed", "markets": ["0xabc123...", "0xdef456..."]}

Price Updates

The server pushes price changes automatically. All fields are at the top level (not nested under a data key):
{
  "type": "price",
  "market_id": "0xabc123...",
  "buy": "0.67",
  "sell": "0.33",
  "best_bid": "0.66",
  "best_ask": "0.68",
  "volume": "125000.50",
  "outcomes": [
    {"label": "Yes", "price": "0.67", "token_id": "71321..."},
    {"label": "No", "price": "0.33", "token_id": "71322..."}
  ],
  "updated_at": "2026-02-06T12:00:45Z"
}
FieldTypeDescription
typestringAlways "price" for price updates
market_idstringPolymarket condition_id
buystringYes outcome price (0–1)
sellstringNo outcome price (0–1)
best_bidstringBest bid price on the order book
best_askstringBest ask price on the order book
volumestring24h trading volume in USD
outcomesarrayPer-outcome {label, price, token_id} breakdown
updated_atstringISO 8601 timestamp of the price source

---

## Unsubscribe

```json
{"action": "unsubscribe", "markets": ["0xabc123..."]}

Complete Example

import asyncio
import json
import requests
import websockets

API_KEY = "ps_live_..."
BASE = "https://api.polysimulator.com/v1"

# Mint WS token
ws_token = requests.post(
    f"{BASE}/keys/ws-token",
    headers={"X-API-Key": API_KEY},
).json()["token"]

async def stream_prices():
    async with websockets.connect(
        f"wss://api.polysimulator.com/v1/ws/prices?token={ws_token}"
    ) as ws:
        # Subscribe to markets
        await ws.send(json.dumps({
            "action": "subscribe",
            "markets": ["0xabc123...", "0xdef456..."],
        }))

        async for raw in ws:
            msg = json.loads(raw)
            if msg["type"] == "price":
                mid = msg["market_id"][:16]
                buy = msg["buy"]
                print(f"{mid}... → Yes: {buy}")

asyncio.run(stream_prices())

Next Steps