Forkast Developer Docs
Websockets
7 min
this is the recommended way to receive real‑time updates such as orderbook changes, market price updates, positions, orders base url wss\ //mgapi forkast gg this server uses socket io over websocket if you are using a raw websocket client, switch to a socket io client library import { io } from "socket io client"; const url = {{base url}}; const opts = { transports \["websocket"], reconnection true, // auth { token "your token here" }, // uncomment and set if needed }; const socket = io(url, opts); socket on("connect", () => { console log("connected", socket id); socket emit("joinroom", "market 1030"); }); socket on("disconnect", (reason) => { console log("disconnected", reason); }); socket on("connect error", (err) => { console error("connection error ", err message); }); // listen for the 'orderbook 1676 0' topic socket on("orderbook 1676 0", (data) => { console log("received orderbook 1676 0 ", data); }); if no token is provided, you will connect as a guest and only receive public events rooms you can subscribe to specific rooms to receive scoped updates auto‑joined user {id} (if authenticated) join manually use joinroom to subscribe to any of the following event {eventid} event comments and reactions market {marketid} market‑level updates (e g , volume) outcome {outcomeid} outcome‑level updates (e g , last price) socket emit("joinroom", "event 123"); topics static topics static topics are fixed, named events that never change you listen to the exact event name and receive all messages the server emits to your connection or room topic description user specifc? update activity global global activity update (all users) no new event created new event created no status event event status update no update cgpc balance user cgpc balance update yes update outcome balance user outcome balance update yes update position user position update yes update activity user activity update yes dynamic topics dynamic topics are constructed at runtime by appending identifiers to the event name you must compute the full topic string for the specific market/outcome you care about and listen to that exact string topic description market trade {marketid} {outcomeid} {outcometype} trade updates scoped to a market/outcome/type orderbook {marketid} {outcometype} orderbook updates for a market and outcome type open order {marketid} {userid} open order stream for a user in a market update price chart {marketid} price chart updates for a market market price {marketid} {outcomeid} {outcometype} price updates scoped to a market/outcome/type