Realtime API
Stream order books, trades, prices, market events and your private notifications over one WebSocket.
Full realtime protocol reference — every channel, event, and sequence/replay rule — docs.drazill.com/realtime ↗
Connecting
Open a WebSocket to /ws. Anonymous connections can subscribe to every public channel. For your private user: stream or the tier-entitled feed, authenticate by sending an auth message first — never put a token in the URL.
const ws = new WebSocket("wss://api.drazill.com/ws");
// 1) authenticate (optional for public channels)
ws.onopen = () => ws.send(JSON.stringify({ type: "auth", api_key: "<DRAZILL_API_KEY>" }));
// 2) subscribe
ws.send(JSON.stringify({ type: "subscribe", channels: ["prices:OUTCOME_ID", "trades:MARKET_ID"] }));Channels
Public market-data channels are open to anonymous browsers. For API-key clients the lighter channels are reachable on the FREE tier, while the full order-book depth and trade tape bind to the ENTERPRISE feed tier.
| Channel | Event(s) | Auth | Feed tier | Replay |
|---|---|---|---|---|
orderbook:{outcome_id}Full order-book depth (bids & asks) for an outcome. | orderbook_update | public | Premium (ENTERPRISE) | ephemeral |
trades:{market_id}Executed trades on a market — the raw tape. | trade | public | Premium (ENTERPRISE) | durable |
prices:{outcome_id}Price-tick updates for an outcome (previous price + % change). | price_tick | public | Public (FREE) | ephemeral |
market:{market_id}Market-level events such as status changes and resolution, plus coalesced live play-by-play ticks (game_play) for sports games. | market_eventgame_play | public | Public (FREE) | durable |
category:{slug}Market events aggregated for a category. | market_event | public | Public (FREE) | durable |
user:{user_id}Your private stream: notifications, order fills/cancels, and wallet updates. Auto-subscribed on connect; requires auth. | notificationorder_filledorder_cancelledwallet_update | owner | — | durable |
chat:{channel_id}Chat messages in a market/category room (membership required). | chat_message | membership | — | ephemeral |
Sequence & replay
Every event carries a monotonically increasing per-channel sequence. Persist the last sequence you processed on each channel; on reconnect, resubscribe and the server replays the durable events you missed (fills, cancels, wallet updates, trades, market events, and everything on your private channel) so a fill is never silently dropped. Ephemeral events (price ticks, order-book snapshots) are superseded by the next message and are not replayed.
Heartbeat
The server sends periodic ping messages; reply with {"type":"pong"} to keep the connection alive.
Sample code (SDK)
import { Drazill } from "drazill";
const ws = new Drazill({ apiKey: "<DRAZILL_API_KEY>" }).ws();
ws.connect();
ws.subscribe("prices:OUTCOME_ID", (data) => console.log("price", data));
ws.subscribe("trades:MARKET_ID", (data) => console.log("trade", data));from drazill import DrazillClient
import asyncio
ws = DrazillClient(api_key="<DRAZILL_API_KEY>").ws()
async def stream():
await ws.connect()
await ws.subscribe("prices:OUTCOME_ID")
async for event in ws.listen():
print(event["type"], event.get("data"))
asyncio.run(stream())