Documentation Index
Fetch the complete documentation index at: https://unitedmarket.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The public real-time API is exposed through the backend Socket.IO endpoint.
| Network | Socket.IO URL |
|---|
| Mainnet | https://backend.themarketunited.com |
| Testnet | https://backend-develop.themarketunited.com |
United Market is currently in sandbox/development stage. All funds, balances, markets, and trades are for testing only and do not represent real money.
Use the Socket.IO client protocol. Do not connect with a plain WebSocket client.
Install Client
npm install socket.io-client
Connect
import { io } from "socket.io-client";
const socket = io("https://backend.themarketunited.com", {
transports: ["websocket", "polling"],
reconnection: true,
});
For testnet:
const socket = io("https://backend-develop.themarketunited.com", {
transports: ["websocket", "polling"],
reconnection: true,
});
Subscribe to a Market
Join a market room with the market conditionId.
const conditionId = "0xd19487c4038d0dce2edeb510a21d6f8534e09d8065d40cb9e10ad2652d86a276";
socket.on("connect", () => {
socket.emit("join:market", conditionId);
});
socket.emit("leave:market", conditionId);
Client Events
| Event | Payload | Description |
|---|
join:market | conditionId: string | Subscribe to one market room. |
leave:market | conditionId: string | Unsubscribe from one market room. |
join:activity | none | Subscribe to global trade activity. |
leave:activity | none | Unsubscribe from global trade activity. |
Server Events
| Event | Description |
|---|
orderbook:update | Emitted when market orderbook state changes. |
trade:new | Emitted when a trade is confirmed on-chain. |
ob:snapshot | L2 orderbook snapshot for an outcome token. |
price:snapshot | Latest bid, ask, and midpoint for an outcome. |
orderbook:update
type OrderbookUpdatePayload = {
conditionId: string;
orderbook: {
type:
| "order:new"
| "order:cancelled"
| "order:matched"
| "order:filled"
| "order:settlement";
orderHash: string;
tokenId: string;
timestamp: number;
data: Record<string, unknown>;
};
};
After this event, clients can refetch GET /markets/{id}/orderbook or GET /markets/{id}/trading.
trade:new
type TradeNewPayload = {
conditionId: string;
trade: {
orderHash: string;
tokenId: string;
timestamp: number;
data: {
maker: string;
taker: string;
makerAmountFilled: string;
takerAmountFilled: string;
fee: string;
txHash: string;
};
};
};
ob:snapshot
type ObSnapshotPayload = {
conditionId: string;
tokenId: string;
bids: Array<[price: number, size: number]>;
asks: Array<[price: number, size: number]>;
timestamp: number;
};
price:snapshot
type PriceSnapshotPayload = {
conditionId: string;
outcomeId: string;
tokenId: string;
bid: number | null;
ask: number | null;
mid: number | null;
timestamp: number;
};
Reconnection
Socket.IO reconnects automatically when configured with reconnection: true. Re-emit join:market subscriptions after reconnecting if your client manages rooms outside a persistent component.