Skip to main content

Documentation Index

Fetch the complete documentation index at: https://pond.dflow.net/llms.txt

Use this file to discover all available pages before exploring further.

During development, you can use the developer endpoints without an API key. For production use, request an API key for higher rate limits.

Market Lifecycle Diagram

Use this lifecycle to decide when to trade and when to redeem. A market can move forward through the sequence and can temporarily pause in inactive.
1

Set up

Imports, env config, and the headers used across every step.
import "dotenv/config";

const DFLOW_METADATA_API_URL = process.env.DFLOW_METADATA_API_URL ?? "https://dev-prediction-markets-api.dflow.net";
const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints

const headers: HeadersInit = {};
if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
2

Understand Market Statuses

Monitor a fixed lifecycle: initialized → active → inactive → closed → determined → finalized.Trade only when status is active. Redeem only when status is determined or finalized, and redemption is funded.
Markets can move from inactive back to active, or from inactive to closed.
3

Get a Market and Read Status

Fetch a market by mint and read the status and redemptionStatus fields.
const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS";

const market = await fetch(
  `${DFLOW_METADATA_API_URL}/api/v1/market/by-mint/${outcomeMint}`,
  { headers }
).then((x) => x.json());

if (!market.status) {
  throw new Error(`No market found for mint "${outcomeMint}". Replace with a real outcome or ledger mint. Response: ${JSON.stringify(market)}`);
}

console.log({
  status: market.status,
  redemptionStatus: market.accounts?.[market.settlementMint]?.redemptionStatus,
});
4

Filter Markets by Status

Filter markets to show only tradable or redeemable markets.
const activeResponse = await fetch(
  `${DFLOW_METADATA_API_URL}/api/v1/markets?status=active&limit=200`,
  { headers }
).then((x) => x.json());

console.log(activeResponse.markets?.length ?? 0);
const determinedResponse = await fetch(
  `${DFLOW_METADATA_API_URL}/api/v1/markets?status=determined&limit=200`,
  { headers }
).then((x) => x.json());

console.log(determinedResponse.markets?.length ?? 0);
5

Gate Trading and Redemption

You gate trades to active markets and gate redemption to determined or finalized markets with redemptionStatus = "open".
if (market.status === "active") {
  // Allow trades
} else {
  // Show market status to the user
}
const settlementAccount = market.accounts?.[market.settlementMint];

if (
  (market.status === "determined" || market.status === "finalized") &&
  settlementAccount?.redemptionStatus === "open"
) {
  // Allow redemption
}

Market Lifecycle

States a market moves through and what each one allows.

Redeem Outcome Tokens

Redeem winning outcome tokens once a market is determined.

Buy Outcome Tokens

Open a prediction market position from any input token.

API Routes