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:
{
  "type": "price",
  "condition_id": "0xabc123...",
  "data": {
    "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"
  },
  "timestamp": "2026-02-06T12:00:46Z"
}

Unsubscribe

{"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":
                cid = msg["condition_id"][:16]
                buy = msg["data"]["buy"]
                print(f"{cid}... → Yes: {buy}")

asyncio.run(stream_prices())

Next Steps