WebSocket Stream Data
The SDK supports both:
- Private account streams (for example
executionReport) - Public market streams (for example
book:{tokenId})
BE WebSocket endpoint: wss://ws.probable.markets/public/api/v1/ws?chainId={chainId}
Private Stream (Authenticated)
Create a client with wsUrl, generate an API key, then subscribe to private events.
type ExecutionReportEvent = {
e: "executionReport";
E: number;
T: number;
u: number;
c: string;
S: "BUY" | "SELL";
o: "LIMIT" | "MARKET";
f: "GTC" | "IOC" | "FOK";
x: "NEW" | "CANCELED" | "REPLACED" | "REJECTED" | "TRADE" | "EXPIRED";
X:
| "NEW"
| "PARTIALLY_FILLED"
| "FILLED"
| "CANCELED"
| "PENDING_CANCEL"
| "REJECTED"
| "EXPIRED";
i: number;
t?: number;
m: boolean;
ot: string;
O: number;
ct: string;
};
const client = createClobClient({
baseUrl: "https://api.probable.markets/public/api/v1",
wsUrl: "wss://ws.probable.markets/public/api/v1",
chainId: 56,
wallet,
});
await client.generateApiKey();
const sub = client.subscribeStreamData("executionReport", (data: ExecutionReportEvent) => {
console.log("Order ID:", data.i);
});
sub.on("ready", (data) => console.log("ready", data?.listenKey));
sub.on("error", (err) => console.error(err));
sub.on("close", () => console.log("closed"));
// Cleanup to prevent leaking WebSocket connections
sub.unsubscribe();Type and fields (ExecutionReportEvent):
e: Event type.E: Event timestamp.T: Transaction timestamp.u: Update sequence identifier from the stream.c: Client order ID.S: Side (BUYorSELL).o: Order type.f: Time-in-force.x: Execution type for this update.X: Current order status.i: Order ID.t: Trade ID (present when a trade is executed).m: Whether this fill/update is maker side.ot: Original order type.O: Order price.ct: CTF token ID.
Public Orderbook Stream
Subscribe to realtime orderbook updates without API-key authentication.
type PublicOrderBookLevel = {
price: string;
size: string;
};
type PublicOrderBookUpdate = {
market?: string;
asset_id?: string;
token_id?: string;
timestamp?: string | number;
hash?: string;
bids: PublicOrderBookLevel[];
asks: PublicOrderBookLevel[];
min_order_size?: string;
tick_size?: string;
neg_risk?: boolean;
topic?: string;
};
const client = createClobClient({
baseUrl: "https://api.probable.markets/public/api/v1",
wsUrl: "wss://ws.probable.markets/public/api/v1",
chainId: 56,
});
const tokenId1 = "743...";
const tokenId2 = "668...";
const sub = client.subscribePublicStream(
[`book:${tokenId1}`, `book:${tokenId2}`],
(data: PublicOrderBookUpdate) => {
console.log("Order book update:", data);
}
);
// Cleanup to prevent leaking WebSocket connections
sub.unsubscribe();Type and fields (PublicOrderBookUpdate):
prob-sdkcurrently does not export a dedicated TS interface forsubscribePublicStreampayloads. The type above is the practical runtime shape for documentation.bids: Buy levels sorted by best price first (highest to lowest).asks: Sell levels sorted by best price first (lowest to highest).price: Price at this level.size: Available size at this level.asset_id/token_id: CTF token identifier for this book.market: Optional market label/symbol.timestamp: Server timestamp for the snapshot/update.hash: Optional book hash/version marker.min_order_size: Minimum order size.tick_size: Minimum price increment.neg_risk: Whether the market has negative-risk configuration.