Skip to main content
During development, you can use the developer endpoints without an API key. In production, use an API key so volume is tracked for fee tiers and rebates. If you use dev endpoints without a key, your volume is not counted.
You include fees in prediction market trades and track fee tiers by volume. If you need the full fee math, use the Fee Formula section.
1

Understand the Fee Model

You pay a probability‑weighted fee based on price, size, and tier. Review the Fee Formula and Fee Tiers before you set pricing expectations.
// Example fee estimation (not a quote).
// scale = tier fee coefficient
// p = fill price in probability terms (0.0 - 1.0)
// c = contracts traded

const scale = 0.09; // Example: Frost tier taker scale
const p = 0.62; // 62% implied probability
const c = 100; // 100 contracts

const fee = scale * p * (1 - p) * c;
console.log(`Estimated fee: ${fee.toFixed(4)} contracts`);
2

Plan for Rebates

You qualify for rebates once you pass volume thresholds. Use the Rebate Program and Rebate Example to estimate your effective fee rate.
const METADATA_API_BASE_URL = "https://dev-prediction-markets-api.dflow.net";
const API_KEY = process.env.DFLOW_API_KEY;

const response = await fetch(
  `${METADATA_API_BASE_URL}/api/v1/trades?limit=200`,
  {
    headers: {
      "Content-Type": "application/json",
      "x-api-key": API_KEY ?? "",
    },
  }
);

if (!response.ok) {
  throw new Error("Failed to fetch trades");
}

const data = await response.json();
const trades = data.trades ?? [];

// Approximate notional = count * priceProbability (price/10000)
const notional = trades.reduce((sum: number, trade: any) => {
  const p = Number(trade.price) / 10000;
  return sum + p * Number(trade.count);
}, 0);

console.log(`Approx 30D notional volume: ${notional}`);

API Routes

Cookbook Repository

This recipe, along with many more, is available in the DFlow Cookbook Repo. You can clone it and start coding immediately.