Building Real-Time Financial Dashboards

Lesson 2 of 2

Integrating Prediction Markets: Polymarket & Kalshi

Estimated time: 10 minutes

Integrating Prediction Markets: Polymarket & Kalshi

Why Prediction Markets?

Prediction markets (Polymarket, Kalshi) offer:

  • Real-time odds on events (sports, elections, economic indicators)
  • High liquidity on major markets
  • Implicit probability forecasts
  • Can be correlated with asset prices for signal detection

Polymarket API

Polymarket is an AMM-based prediction market. It offers an HTTP API with no authentication required.

Base URL

https://polymarket.com/api/

Endpoints

Get all markets:

curl 'https://polymarket.com/api/markets?category=sports'

Response includes: market_id, title, outcomes, prices, volume, liquidity.

Get specific market:

curl 'https://polymarket.com/api/markets/{market_id}'

Example: Fetch Super Bowl Odds

const fetch = require('node-fetch');

async function getPolymarketOdds(category = 'sports') {
  const res = await fetch(`https://polymarket.com/api/markets?category=${category}`);
  const markets = await res.json();
  
  return markets.map(m => ({
    title: m.title,
    id: m.market_id,
    outcomes: m.outcomes,
    prices: m.prices,  // [0.35, 0.65] for two outcomes
    volume: m.volume_24h
  }));
}

const odds = await getPolymarketOdds();
console.log(odds);

Kalshi API

Kalshi is a regulated U.S. prediction market exchange. It requires OAuth but offers better coverage and liquidity on certain markets.

Key Differences from Polymarket

  • Requires API key (free to register)
  • Prices in cents (0-100, divide by 100 for odds)
  • Higher minimum order size
  • Better for U.S. regulatory/sports markets

Base URL

https://api.elections.kalshi.com/trade-api/v2

Endpoints

Get series (list of available markets):

curl 'https://api.elections.kalshi.com/trade-api/v2/series?status=active'

Get specific market:

curl 'https://api.elections.kalshi.com/trade-api/v2/markets?series_ticker=KXSB'

Rate Limits

  • Polymarket: ~100 requests/second (generous)
  • Kalshi: 10 requests/second per API key

Caching Strategy

Prediction market data changes constantly, but caching for 30-60 seconds is safe to respect rate limits.

Next Steps

Build a real-time dashboard that displays stock prices and market odds side-by-side.