๐Ÿ”Œ Websockets

Learn to connect via Socket.IO WebSockets, join rooms, and subscribe to static and dynamic topics for real-time market and user updates.

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.

TopicDescriptionUser Specifc?
update_activity_globalGlobal activity update (all users).No
new_event_createdNew event created.No
status_eventEvent status update.No
update_cgpc_balanceUser CGPC balance update.Yes
update_outcome_balanceUser outcome balance update.Yes
update_positionUser position update.Yes
update_activityUser 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.

TopicDescription
market_trade_{marketId}Trade updates scoped to a market.
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.

Explore the sections below for comprehensive response details and implementation examples:

  1. Market Updates
  2. User Updates