majjha.developers
Open beta

Public beta: activity uses test Dots with no monetary value. There is no money in or out, and interfaces may change before launch.

WebSocket

One socket, many markets. Subscribe to order-book and ticker channels to receive a fresh snapshot on every change.

Connect

Open a WebSocket to the realtime endpoint. Public market channels need no authentication.

WSwss://api.majjha.fun/ws

Local development

Against a local engine, use ws://localhost:7890/ws. The protocol is identical to the hosted beta.

Subscribe

Send a JSON command with cmd: "subscribe"and a list of channels. Market channels use the market's internal id, not its ticker. Sports channels use a sport slug. One socket may hold up to 64 channels.

Subscribe
{
  "cmd": "subscribe",
  "channels": [
    "orderbook.mkt_btc5m_a1",
    "ticker.mkt_btc5m_a1"
  ]
}

Unsubscribe with the same shape and cmd: "unsubscribe".

Unsubscribe
{
  "cmd": "unsubscribe",
  "channels": ["ticker.mkt_btc5m_a1"]
}

Channels

  • orderbook.<market_id> — full order-book snapshot on every change.
  • ticker.<market_id> — best bid, best ask, spread, and midpoint.
  • trades.<market_id> — public trade tape for one market.
  • price.<asset> — underlying reference-price updates, such as price.btc.
  • sports.all or sports.<sport_slug> — sports slate snapshots and updates.

Server messages

Each push is a JSON frame tagged with a type and channel. The resource-specific payload appears under data.

Order-book frame
{
  "type": "orderbook",
  "channel": "orderbook.mkt_btc5m_a1",
  "data": {
    "bids": [{ "price": "0.53", "quantity": "120", "order_count": 3 }],
    "asks": [{ "price": "0.55", "quantity": "90", "order_count": 2 }],
    "best_bid": "0.53",
    "best_ask": "0.55",
    "spread": "0.02",
    "mid_price": "0.54"
  }
}
Ticker frame
{
  "type": "ticker",
  "channel": "ticker.mkt_btc5m_a1",
  "data": {
    "market_id": "mkt_btc5m_a1",
    "best_bid": "0.53",
    "best_ask": "0.55",
    "spread": "0.02",
    "mid_price": "0.54"
  }
}
Sports snapshot
{
  "type": "sports_snapshot",
  "channel": "sports.football",
  "sport": "football",
  "data": {
    "events": [
      {
        "event_ticker": "NFL-KC-BUF-2026-09-12",
        "title": "Chiefs vs Bills",
        "league_slug": "nfl",
        "scheduled_start": "2026-09-12T01:20:00"
      }
    ]
  }
}

Browser example

subscribe.js
const ws = new WebSocket("wss://api.majjha.fun/ws");

ws.addEventListener("open", () => {
  ws.send(JSON.stringify({
    cmd: "subscribe",
    channels: ["orderbook.mkt_btc5m_a1", "ticker.mkt_btc5m_a1"],
  }));
});

ws.addEventListener("message", (event) => {
  const frame = JSON.parse(event.data);
  if (frame.type === "ticker") {
    console.log("mid", frame.data.mid_price);
  }
});

Single-market shortcut

The push-only endpoint /ws/markets/{id}streams one market's order book without a subscription command.

Reconnect safely

  • Reconnect with exponential backoff and a small random delay.
  • Resubscribe only after the socket reports that it is open.
  • Refresh the current REST resource after reconnecting before applying new frames.
  • Treat unknown fields as additive so beta clients remain forward compatible.