Skip to main content
During development, you can use the developer endpoints without an API key. For production use, you’ll need an API key to avoid rate limits.
Track market status to know when trading is allowed and when redemption is available. Use the Metadata API to query status and filter by state.

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

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.
2

Get a Market and Read Status

Fetch a market by mint and read the status and redemptionStatus fields.
const METADATA_API_BASE_URL = "https://dev-prediction-markets-api.dflow.net";
const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS";

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

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

Filter Markets by Status

Filter markets to show only tradable or redeemable markets.
const METADATA_API_BASE_URL = "https://dev-prediction-markets-api.dflow.net";

const response = await fetch(
  `${METADATA_API_BASE_URL}/api/v1/markets?status=active&limit=200`
).then((x) => x.json());

console.log(response.markets?.length ?? 0);
const METADATA_API_BASE_URL = "https://dev-prediction-markets-api.dflow.net";

const response = await fetch(
  `${METADATA_API_BASE_URL}/api/v1/markets?status=determined&limit=200`
).then((x) => x.json());

console.log(response.markets?.length ?? 0);
4

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
}

KYC Requirements

Prediction market applications must use Proof to meet Kalshi compliance requirements.

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.

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.