Skip to main content
WSS wss://ws-gateway.dev.predictstreet.sde.adifoundation.ai/ws/market
Market-data gateway. Use for the public trade tape, orderbook snapshots + deltas, market lifecycle, and the platform-wide status banner. Trying to subscribe to a private channel (user_activity) on this gateway returns { "code": "forbidden" } in the rejected[] array — use /ws/market for own-activity streams.

Authentication

Same X-Api-Key scheme as the rest of the API — no separate auth scheme for market data:
How to send it
X-Api-Key: ps_live_<keyId>_<secret> header on the upgrade request
?key=<token> query parameter — for browser clients that can’t set custom headers on the WebSocket upgrade
Market channels do not require any specific scope — any active key can subscribe. Missing or invalid keys are rejected at handshake with 4401 <reason> (same close-code matrix as /ws/user). Revoking a key closes every live socket bound to that keyId immediately via Redis pub/sub.

Connect greeting

{ "type": "connected", "data": { "gateway": "market", "authMethod": "api_key" } }

Available channels

Channelids shapeServer pushes
token_tradesone or more tokenId (decimal string)trade per public fill
token_bookone or more tokenId (decimal string)book_snapshot once on subscribe, then book_delta (see status note below)
condition_statusone or more conditionId (lowercased bytes32 hex)market_paused / market_unpaused / market_resolved / market_status
systemmust be ["platform_status"]platform_status (frozen / maintenance banner)
See Server events for full payload shapes per type.
Live status: token_trades + system push reliably today. condition_status accepts subscribes but has no upstream emitter yet. token_book accepts subscribes but neither book_snapshot nor book_delta is pushed currently — a backend fix is planned to wire the matcher → gateway pipeline. Until then, fall back to GET /api/markets/{symbol}/orderbook for snapshots.

tokenId and conditionId come from REST

Subscribe by on-chain native ids, never by app symbol.
curl -H "X-Api-Key: ps_live_..." \
  https://core.api.dev.predictstreet.sde.adifoundation.ai/api/markets/NC26-BIN-83479265
{
  "symbol":      "NC26-BIN-83479265",
  "conditionId": "0x22a88c544e7ab9...",
  "yesTokenId":  "60550363974013526351721227761627460394700175914670861601864197814576471666136",
  "noTokenId":   "3448474776790199743770418424395373406530354266022486190942562054524211572097",
  ...
}
For neg-risk multi-outcome markets each question carries its own conditionId; resolve outcome token ids through the on-chain NegRiskAdapter before subscribing.

Subscribe example

import WebSocket from 'ws';

const KEY = process.env.PREDICTSTREET_API_KEY;
const ws = new WebSocket(
  'wss://ws-gateway.dev.predictstreet.sde.adifoundation.ai/ws/market',
  { headers: { 'X-Api-Key': KEY } },
);

ws.on('open', () => {
  ws.send(JSON.stringify({
    id: 1,
    cmd: 'subscribe',
    params: {
      subscriptions: [
        { channel: 'token_trades',     ids: ['60550363974013526351721227761627460394700175914670861601864197814576471666136'] },
        { channel: 'token_book',       ids: ['60550363974013526351721227761627460394700175914670861601864197814576471666136'] },
        { channel: 'condition_status', ids: ['0x22a88c544e7ab9...'] },
        { channel: 'system',           ids: ['platform_status'] },
      ],
    },
  }));
});

ws.on('message', (raw) => {
  const ev = JSON.parse(raw.toString('utf8'));
  // route on ev.type / ev.channel / ev.sid / ev.id
});

Subscribe response

{
  "id": 1,
  "type": "subscribed",
  "accepted": [
    { "sid": 10, "channel": "token_trades",     "ids": ["60550363974013526351721227761627460394700175914670861601864197814576471666136"] },
    { "sid": 11, "channel": "token_book",       "ids": ["60550363974013526351721227761627460394700175914670861601864197814576471666136"] },
    { "sid": 12, "channel": "condition_status", "ids": ["0x22a88c544e7ab9..."] },
    { "sid": 13, "channel": "system",           "ids": ["platform_status"] }
  ],
  "rejected": []
}

Rejection codes

codeWhen
invalid_paramsunknown channel, malformed tokenId / conditionId, missing required ids, or system ids not ["platform_status"]
forbiddentried a private channel (user_activity) on this gateway

Commands

update_subscription / unsubscribe / list_subscriptions / ping.

Server events

Full event payload catalog per channel.