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, you’ll need an
API key to avoid rate limits.
Use the onchain trades endpoints to power activity feeds, trade analytics, and
wallet-level history views.
Use Cases
- Display global “recent fills” across all markets.
- Display market-specific fills next to orderbook and price data.
- Display wallet trade history scoped to a market or event.
- Trigger alerts for large trades using
minAmount filters.
Set Base URL and Query Helper
Define the metadata API base URL and reusable query/output helpers.
const METADATA_API_BASE_URL = "https://dev-prediction-markets-api.dflow.net";
type QueryValue = string | number | undefined | null;
type OnchainTrade = Record<string, any>;
function toQueryString(params: Record<string, QueryValue>): string {
const searchParams = new URLSearchParams();
Object.entries(params).forEach(([key, value]) => {
if (value !== undefined && value !== null && value !== "") {
searchParams.set(key, String(value));
}
});
const query = searchParams.toString();
return query ? `?${query}` : "";
}
function printTrades(trades: OnchainTrade[]) {
trades.forEach((trade) => {
console.log({
id: trade.id,
createdAt: trade.createdAt,
marketTicker: trade.marketTicker,
side: trade.side,
inputAmount: trade.inputAmount,
outputAmount: trade.outputAmount,
wallet: trade.wallet,
transactionSignature: trade.transactionSignature,
});
});
}
Get Onchain Trades by Wallet
Scope fills to a single wallet using /api/v1/onchain-trades with the
wallet query parameter.Pure Wallet Filter (Global Onchain Trades)
const wallet = "XJfdwGBgXMa1cXdiU4fqceoBLkgtTCr6S863k8xmh9A";
const response = await fetch(
`${METADATA_API_BASE_URL}/api/v1/onchain-trades?wallet=${wallet}&limit=100&sortBy=createdAt&sortOrder=desc`
);
if (!response.ok) {
throw new Error("Failed to fetch wallet onchain trades");
}
const data = await response.json();
const trades = data.trades ?? [];
const nextCursor = data.cursor ?? null;
printTrades(trades);
console.log({
wallet,
tradeCount: trades.length,
nextCursor,
});
Get Onchain Trades Across All Markets
Scope fills across all markets using /api/v1/onchain-trades.Fetch Global Onchain Trades
const query = toQueryString({
limit: 100,
cursor: undefined,
mint: undefined, // optional
ticker: undefined, // optional
sortBy: "createdAt",
sortOrder: "desc",
minAmount: undefined,
maxAmount: undefined,
});
const response = await fetch(
`${METADATA_API_BASE_URL}/api/v1/onchain-trades${query}`
);
if (!response.ok) {
throw new Error("Failed to fetch onchain trades");
}
const data = await response.json();
const trades = data.trades ?? [];
const nextCursor = data.cursor ?? null;
printTrades(trades);
console.log({ tradeCount: trades.length, nextCursor });
Get Onchain Trades by Event
Scope fills to all markets inside a single event using
/api/v1/onchain-trades/by-event/{event_ticker}.Fetch Event Onchain Trades
const eventTicker = "KXBTCY-27JAN0100";
const query = toQueryString({
limit: 100,
sortBy: "createdAt",
sortOrder: "desc",
minAmount: undefined,
maxAmount: undefined,
});
const response = await fetch(
`${METADATA_API_BASE_URL}/api/v1/onchain-trades/by-event/${eventTicker}${query}`
);
if (!response.ok) {
throw new Error("Failed to fetch onchain trades by event");
}
const data = await response.json();
const trades = data.trades ?? [];
const nextCursor = data.cursor ?? null;
printTrades(trades);
console.log({
eventTicker,
tradeCount: trades.length,
nextCursor,
});
Get Onchain Trades by Market
Scope fills to a single market using
/api/v1/onchain-trades/by-market/{market_ticker}.Fetch Market Onchain Trades
const marketTicker = "KXBTCY-27JAN0100-B82500";
const query = toQueryString({
limit: 100,
sortBy: "createdAt",
sortOrder: "desc",
minAmount: undefined,
maxAmount: undefined,
});
const response = await fetch(
`${METADATA_API_BASE_URL}/api/v1/onchain-trades/by-market/${marketTicker}${query}`
);
if (!response.ok) {
throw new Error("Failed to fetch onchain trades by market");
}
const data = await response.json();
const trades = data.trades ?? [];
const nextCursor = data.cursor ?? null;
printTrades(trades);
console.log({
marketTicker,
tradeCount: trades.length,
nextCursor,
});
Paginate with Cursor
Scope historical pagination by passing each response cursor into the next
/api/v1/onchain-trades request.
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.