Skip to main content
The prices channel streams real-time bid and ask price updates for prediction markets. Use this channel to build live price tickers, trading interfaces, and market monitoring tools.

Connection

See the WebSocket overview for connection setup and endpoint details.

Subscribe

Subscribe to All Prices

{
  "type": "subscribe",
  "channel": "prices",
  "all": true
}

Subscribe to Specific Tickers

{
  "type": "subscribe",
  "channel": "prices",
  "tickers": ["BTCD-25DEC0313-T92749.99", "SPX-25DEC0313-T5000"]
}

Unsubscribe

Unsubscribe from All Prices

{
  "type": "unsubscribe",
  "channel": "prices",
  "all": true
}

Unsubscribe from Specific Tickers

{
  "type": "unsubscribe",
  "channel": "prices",
  "tickers": ["BTCD-25DEC0313-T92749.99"]
}

Response Format

When subscribed to the prices channel, you’ll receive messages with the following structure:
{
  "channel": "prices",
  "type": "ticker",
  "market_ticker": "BTCD-25DEC0313-T92749.99",
  "yes_bid": "0.45",
  "yes_ask": "0.47",
  "no_bid": "0.53",
  "no_ask": "0.55"
}

Response Fields

FieldTypeDescription
channelstringAlways "prices"
typestringMessage type
market_tickerstringMarket identifier
yes_bidstring | nullBest bid price for YES outcome
yes_askstring | nullBest ask price for YES outcome
no_bidstring | nullBest bid price for NO outcome
no_askstring | nullBest ask price for NO outcome
Price fields may be null if there is no current bid or ask at that level.

Code Examples

// Dev endpoint — no API key required, but rate-limited.
// For production, use your production WS URL and add:
//   { headers: { "x-api-key": "YOUR_API_KEY" } }
// as the second argument to new WebSocket().
const WS_URL = "wss://dev-prediction-markets-api.dflow.net/api/v1/ws";

const ws = new WebSocket(WS_URL);

ws.onopen = () => {
  console.log("Connected to WebSocket");

  // Subscribe to all price updates
  ws.send(
    JSON.stringify({
      type: "subscribe",
      channel: "prices",
      all: true,
    })
  );
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);

  if (message.channel === "prices") {
    console.log("Price update:", {
      ticker: message.market_ticker,
      yesBid: message.yes_bid,
      yesAsk: message.yes_ask,
      noBid: message.no_bid,
      noAsk: message.no_ask,
    });
  }
};

ws.onerror = (error) => {
  console.error("WebSocket error:", error);
};

ws.onclose = () => {
  console.log("WebSocket connection closed");
};
// Dev endpoint — no API key required, but rate-limited.
// For production, use your production WS URL and add:
//   { headers: { "x-api-key": "YOUR_API_KEY" } }
// as the second argument to new WebSocket().
const WS_URL = "wss://dev-prediction-markets-api.dflow.net/api/v1/ws";

// Market tickers to subscribe to
const marketTickers = ["BTCD-25DEC0313-T92749.99", "SPX-25DEC0313-T5000"];

const ws = new WebSocket(WS_URL);

ws.onopen = () => {
  console.log("Connected to WebSocket");

  // Subscribe to specific tickers for prices
  ws.send(
    JSON.stringify({
      type: "subscribe",
      channel: "prices",
      tickers: marketTickers,
    })
  );
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  console.log(`Price update for ${message.market_ticker}:`, message);
};
interface PriceUpdate {
  channel: "prices";
  type: string;
  market_ticker: string;
  yes_bid: string | null;
  yes_ask: string | null;
  no_bid: string | null;
  no_ask: string | null;
}

function handlePriceUpdate(update: PriceUpdate) {
  console.log(`Price update for ${update.market_ticker}:`, {
    yesBid: update.yes_bid,
    yesAsk: update.yes_ask,
    noBid: update.no_bid,
    noAsk: update.no_ask,
  });
}

Trades Channel

Subscribe to real-time trade execution updates

Orderbook Channel

Subscribe to real-time orderbook depth updates

Live Data API

Get live data snapshots via REST API

Need Help?

https://mintcdn.com/dflow/a8Yx7HBusmKl4Z7w/images/meteor-icons_discord.svg?fit=max&auto=format&n=a8Yx7HBusmKl4Z7w&q=85&s=0ea834bc8a9fa3fe161ba181329effda

Join Our Discord

Connect with other developers, get help, and stay updated on the latest DFlow developments.
https://mintcdn.com/dflow/a8Yx7HBusmKl4Z7w/images/meteor-icons_telegram.svg?fit=max&auto=format&n=a8Yx7HBusmKl4Z7w&q=85&s=e928c5dd68311ff0d419936a35c86eed

Dev Notifications

Join the DFlow Dev Notifications Telegram group to stay in the loop on new features and other announcements.