Live Data API

Access real-time market data and milestones

Live Data API

The Live Data API provides access to real-time milestone and progress data for prediction markets. These endpoints relay data directly from the Kalshi API.

Access

const dflow = new DFlowClient();
const liveData = dflow.liveData;

Methods

getLiveData

Get live data for specific milestones.

const data = await dflow.liveData.getLiveData(['milestone-1', 'milestone-2']);
data.forEach(d => console.log(`${d.milestones[0]?.name}: ${d.milestones[0]?.value}`));

Parameters:

NameTypeRequiredDescription
milestoneIdsstring[]YesArray of milestone identifiers (max 100)

Returns: LiveData[]


getLiveDataByEvent

Get live data for an event by ticker. Fetches all live data for an event by automatically looking up related milestones.

// Get all live data for an event
const data = await dflow.liveData.getLiveDataByEvent('BTCD-25DEC0313');
 
// Filter by category
const sportsData = await dflow.liveData.getLiveDataByEvent('SPORTS-EVENT', {
  category: 'sports',
  competition: 'NFL',
});

Parameters:

NameTypeRequiredDescription
eventTickerstringYesThe event ticker
params.minimumStartDatestringNoMinimum start date (RFC3339 format)
params.categorystringNoFilter by milestone category
params.competitionstringNoFilter by competition
params.sourceIdstringNoFilter by source ID
params.typestringNoFilter by milestone type

Returns: LiveData


getLiveDataByMint

Get live data by market mint address.

const data = await dflow.liveData.getLiveDataByMint('EPjFWdd5...');
 
// With filters
const filteredData = await dflow.liveData.getLiveDataByMint('EPjFWdd5...', {
  type: 'price',
});

Parameters:

NameTypeRequiredDescription
mintAddressstringYesMarket mint address (ledger or outcome mint)
params.minimumStartDatestringNoMinimum start date (RFC3339 format)
params.categorystringNoFilter by milestone category
params.competitionstringNoFilter by competition
params.sourceIdstringNoFilter by source ID
params.typestringNoFilter by milestone type

Returns: LiveData


Examples

Monitor Event Live Data

const eventTicker = 'BTCD-25DEC0313';
 
const liveData = await dflow.liveData.getLiveDataByEvent(eventTicker);
 
console.log(`Live data for ${eventTicker}:`);
console.log(liveData);

Get Live Data with Filters

const data = await dflow.liveData.getLiveDataByEvent('SPORTS-EVENT', {
  category: 'sports',
  competition: 'NFL',
  type: 'score',
});

Get Live Data by Market Mint

const market = await dflow.markets.getMarket('BTCD-25DEC0313-T92749.99');
const accountKey = Object.keys(market.accounts)[0];
const yesMint = market.accounts[accountKey].yesMint;
 
const liveData = await dflow.liveData.getLiveDataByMint(yesMint);
console.log(liveData);

WebSocket for Real-time Updates

For continuous real-time updates, consider using the WebSocket API:

await dflow.ws.connect();
 
// Subscribe to price updates
dflow.ws.subscribePrices(['BTCD-25DEC0313-T92749.99']);
 
dflow.ws.onPrice((update) => {
  console.log(`${update.ticker}: YES=${update.yesPrice} NO=${update.noPrice}`);
});

See the WebSocket API for more details.

On this page