Stream real-time orderbook updates for multiple outcomes via WebSocket
WebSocket endpoint — This method uses WebSocket streaming, not HTTP. Connect to wss://api.pmxt.dev/ws?apiKey=YOUR_KEY (hosted) or ws://localhost:3847/ws (local server).
Fetch a market’s outcomes, then stream all their orderbooks:
import pmxtpoly = pmxt.Polymarket(pmxt_api_key="YOUR_PMXT_API_KEY")# Get all outcomes for a marketmarket = poly.fetch_market(market_id="MARKET_ID")ids = [o.outcome_id for o in market.outcomes]# Stream all orderbookswhile True: books = poly.watch_order_books(ids) for outcome_id, book in books.items(): mid = (book.bids[0].price + book.asks[0].price) / 2 if book.bids and book.asks else 0 print(f"{outcome_id[:20]}... mid={mid:.1%}")