Forkast Developer Docs
Websockets
User Updates
6 min
to receive real time updates about your positions, activities, and tc balance, you must connect to the socket server as an authenticated user import { io } from "socket io client"; const url = "{{base url}}"; const opts = { transports \["websocket"], reconnection true, auth { token "your token here" }, // set your jwt or session token here }; const socket = io(url, opts); socket on("connect", () => { console log("connected", socket id); // optionally join a room if needed // socket emit("joinroom", "user 123"); // example join a user specific room }); socket on("disconnect", (reason) => { console log("disconnected", reason); }); socket on("connect error", (err) => { console error("connection error ", err message); }); // listen for user specific events socket on("update position", (data) => { console log("received update position ", data); }); socket on("update activity", (data) => { console log("received update activity ", data); }); socket on("update cgpc balance", (data) => { console log("received update cgpc balance ", data); }); get tc balance updates sent when your tc/usdc token balance or related wallet information changes event update cgpc balance field type description id string balance record id createdat string record creation iso timestamp updatedat string last update iso timestamp deletedat string | null deletion timestamp (if deleted) userid number user identifier balanceusdc string usdc balance lockbalanceusdc string locked usdc balance balanceusdt string usdt balance lockbalanceusdt string locked usdt balance balancecgpc number tc token balance lockbalancecgpc string locked cgpc balance walletproxyaddress string proxy wallet address walletaddress string user’s wallet address tradegap string trade gap value lastrewardclaimedat string last reward claim iso timestamp get new positions sent when your position in a market is updated event update position field type description id string position id marketid string market identifier amount number number of shares held outcomeid string outcome identifier outcometitle string outcome name (e g , "yes", "no") eventid number event identifier marketquestion string the market’s question marketstatus enum market status (active, closed, etc ) marketimage string image url for the market avgprice number average price paid latestprice number most recent price currentvalue number current value of your position betvalue number total amount you’ve bet pnl number profit and loss (decimal) winvalue number value if your outcome wins get activity of the user sent when a new activity (trade) is recorded for your account event update activity field type description id string activity id amount number amount traded price number price per unit total number total value of the trade type enum activity type (buy, sell, etc ) createdat string iso timestamp of the activity txhash string blockchain transaction hash marketid string market identifier markettitle string market title marketquestion string market’s question marketimage string image url for the market eventid number event identifier outcomeid string outcome identifier outcometitle string outcome name outcometype number outcome type (numeric) abbreviation string|null abbreviation (if any) slug string slug for the event/market rewardtoken string | null reward token (if any) get outcome balance sent when your balance or locked balance for a specific outcome token is updated this event notifies you of changes to your holdings for a particular outcome in a market event update outcome balance field type description id string outcome balance record id createdat string record creation iso timestamp updatedat string last update iso timestamp deletedat string|null deletion timestamp (if deleted) userid number user identifier outcomeid number outcome identifier tokenid string token identifier for the outcome balance number current balance for this outcome lockedbalance string locked balance for this outcome get open orders emitted to provide the list of open orders for a user in a specific market field type description id string order id market id number market id orders address string address associated with the order orders amount string total order amount orders filled amount string amount already filled orders outcome type number outcome type (e g , 0 = no, 1 = yes) orders price string order price orders remaining amount string remaining amount to be filled orders side number order side (0 = buy, 1 = sell) orders status number status code of the order orders expired null/number expiry timestamp or null orders type number type of order outcome id number outcome id outcome title string outcome title orders total string total value of the order market image string url to market image