Kalshi is the first CFTC-regulated prediction market exchange in the US. Unlike Polymarket, which settles on-chain in crypto, Kalshi is a regulated exchange where members trade event contracts in dollars. That distinction matters: it brings a different user base, different markets (heavy on economics, weather, and sports), and a different API.
Kalshi's own API is well documented and built for trading. But if you want enriched market data, ranked event lists, sub-day stats, historical probability charts, or Kalshi data side by side with Polymarket, the native API makes you do all of that work yourself.
This guide covers both: how Kalshi's native API works, and how to get enriched Kalshi data through the Codex prediction markets API, with working Python code for each.
What Data Is Available on Kalshi?
Through one route or the other, you can access:
- Series, events, and markets: Kalshi organizes contracts as series (recurring templates like "Fed rate decision"), events (a specific instance), and markets (individual YES/NO contracts)
- Current prices: last trade price per side, which doubles as implied probability
- Order books: live bids and asks per market
- Volume and open interest: how much money is behind each market
- Trade history: individual executions with price, size, and side
- Settlement data: how markets resolved
- Historical probabilities: how prices moved over time
Kalshi's Native API
Kalshi exposes a REST API plus WebSocket feeds, documented at docs.kalshi.com. Market data endpoints are publicly readable; trading requires an API key with signed requests.
Listing open markets from Python is straightforward:
import requests
resp = requests.get(
"https://api.elections.kalshi.com/trade-api/v2/markets",
params={"status": "open", "limit": 10},
)
for market in resp.json()["markets"]:
print(f'{market["ticker"]}: {market["title"]} | yes_bid={market["yes_bid"]}')
Prices are quoted in cents: a YES bid of 62 means the market implies a 62% probability.
Strengths of the native API
- Order book access. Full depth per market, which Codex also mirrors but the native API is the source.
- Trading. Placing and managing orders is only possible through Kalshi's API.
- Good documentation. Clear endpoint reference with a proper getting-started flow.
Where it falls short for data products
- No sort parameters. The
/eventsand/marketsendpoints expose no ranking at all. To answer "what are the top Kalshi markets by 24h volume?" you page through every open event and sort client-side. - One stat window. You get
volume_24hand little else. No 5m/1h/4h/12h/1w windows, no trade counts, no unique-trader counts, no liquidity or open interest change. - Events are pure metadata. An event object carries no aggregated stats. Rolling up volume, open interest, and trader counts across an event's child markets is your job.
- Rate limits. Roughly 20 requests per second on standard access. Combined with the lack of server-side ranking, building a "trending markets" view means a lot of requests.
- Kalshi only. Polymarket often lists the same real-world events. Comparing odds across venues means integrating a second API with a second schema.
Getting Kalshi Data Through Codex
Codex indexes Kalshi and Polymarket into one GraphQL schema and computes the enrichment the native APIs skip: server-side rankings, trending scores, stats windowed from 5 minutes to 1 week, event-level rollups, OHLC probability history, and trader analytics. Prediction market endpoints are available on the Growth plan.
The Python helper from our Polymarket API guide works unchanged; everything is a POST to https://graph.codex.io/graphql with your key in the Authorization header:
import requests
CODEX_API_KEY = "YOUR_API_KEY"
CODEX_URL = "https://graph.codex.io/graphql"
def codex(query, variables=None):
resp = requests.post(
CODEX_URL,
headers={"Authorization": CODEX_API_KEY, "Content-Type": "application/json"},
json={"query": query, "variables": variables or {}},
)
resp.raise_for_status()
return resp.json()["data"]
Top Kalshi events by 24h volume, one query
The query that takes "page everything and sort client-side" on the native API is one call on Codex, with event-level rollups included:
TOP_KALSHI = """
query TopKalshiEvents {
filterPredictionEvents(
filters: { protocol: [KALSHI], status: [OPEN] }
rankings: [{ attribute: volumeUsd24h, direction: DESC }]
limit: 10
) {
results {
event { question venueUrl closesAt }
marketCount
categories
volumeUsd24h
trades24h
uniqueTraders24h
liquidityUsd
openInterestUsd
}
}
}
"""
data = codex(TOP_KALSHI)
for row in data["filterPredictionEvents"]["results"]:
vol = float(row["volumeUsd24h"] or 0)
print(f'{row["event"]["question"]} | ${vol:,.0f} 24h | {row["marketCount"]} markets')
Swap volumeUsd24h for trendingScore1h and you have a "what is moving right now" feed, a ranking signal the native API has no equivalent for.
Current odds with bid, ask, and spread
filterPredictionMarkets returns Kalshi markets with prices inline. For a single-market quote with top-of-book detail, predictionMarketPrice returns best bid, best ask, last trade, and spread per outcome, in both USD and collateral terms (cents, for Kalshi):
MARKET_QUOTE = """
query Quote($marketId: String!) {
predictionMarketPrice(input: { marketId: $marketId }) {
outcomes {
outcomeId
lastTradePriceUsd
bestBidUsd
bestAskUsd
spreadUsd
}
}
}
"""
Historical probability charts
predictionMarketBars returns OHLC bars per outcome at resolutions from 1 minute to 1 week, so charting how a Kalshi probability moved is one query rather than a data collection project:
import time
HISTORY = """
query KalshiHistory($marketId: String!, $from: Int!, $to: Int!) {
predictionMarketBars(input: {
marketId: $marketId
from: $from
to: $to
resolution: hour4
}) {
bars {
t
volumeUsd
outcome0 { priceUsd { o h l c } }
}
}
}
"""
now = int(time.time())
data = codex(HISTORY, {"marketId": "KALSHI_MARKET_ID", "from": now - 30 * 86400, "to": now})
Cross-Venue Comparison: The Killer Use Case
The same real-world event frequently trades on both Kalshi and Polymarket, and the implied probabilities do not always agree. With two separate vendor APIs, comparing them is an integration project. With one schema, it is a single text search across both venues:
CROSS_VENUE = """
query CrossVenue($phrase: String!) {
filterPredictionEvents(
phrase: $phrase
filters: { protocol: [POLYMARKET, KALSHI], status: [OPEN] }
rankings: [{ attribute: volumeUsd24h, direction: DESC }]
limit: 10
) {
results {
protocol
event { question venueUrl }
volumeUsd24h
liquidityUsd
}
}
}
"""
data = codex(CROSS_VENUE, {"phrase": "fed rate"})
for row in data["filterPredictionEvents"]["results"]:
print(f'[{row["protocol"]}] {row["event"]["question"]}')
From here, pull each event's markets with filterPredictionMarkets, line up the matching outcomes, and you have a cross-venue odds comparison: the foundation for arbitrage monitors, best-price routers, and aggregator UIs. This is the one capability that neither native API can offer, because each one ends at its own venue.
Kalshi API vs Codex: When to Use Which
Same conclusion as on the Polymarket side: trade through the venue's API, read through Codex. The two compose cleanly because the heavy data lifting happens before your code ever touches the exchange.
Getting Started
- For trading on Kalshi, start with Kalshi's API docs. Generate an API key from your account settings and use their signed-request flow.
- For data, analytics, and cross-venue work, get a Codex API key at dashboard.codex.io/signup. Prediction market endpoints are on the Growth plan, which also unlocks the
onPredictionTradesCreatedWebSocket stream for live Kalshi trade feeds. - Browse the prediction market section of the Codex API reference for the full query list, including trader analytics (
filterPredictionTraders,predictionTraderHoldings) and order books (predictionOutcomeOrderBooks).
If you are also working with Polymarket, our Polymarket API guide covers the same patterns on the other venue, and the Polymarket trading bot guide shows the data layer feeding an automated strategy.
FAQ
Does Kalshi have an API?
Yes. Kalshi offers a well-documented REST API plus WebSocket feeds at docs.kalshi.com. Market data endpoints are publicly readable, and trading requires an API key with signed requests. For enriched data such as server-side rankings, windowed stats, event rollups, and historical OHLC probabilities, third-party APIs like Codex index Kalshi into a richer schema.
How do I use the Kalshi API?
For raw market data, send GET requests to Kalshi's /markets and /events endpoints. For trading, authenticate with an API key and use their order endpoints. For analytics-grade data, query the Codex GraphQL API with filters: { protocol: [KALSHI] }: ranked event lists, market prices with bid/ask/spread, probability history, and live trade streams, all in one schema.
Is the Kalshi API free?
Kalshi's market data endpoints are free to read, with rate limits of roughly 20 requests per second and no server-side ranking or windowed stats. Codex's prediction market endpoints require a Growth plan (from $350/month for 1M requests), which is aimed at production data products rather than personal scripts.
Can you build a trading bot for Kalshi?
Yes. Kalshi permits API trading, and its regulated order book structure suits market making and event-driven strategies. The standard architecture is Codex as the data and signal layer (rankings, odds history, trade streams across Kalshi and Polymarket) with Kalshi's API as the execution layer. Cross-venue signals are a common edge, since the same event often prices differently on Polymarket.
What is the difference between Kalshi and Polymarket APIs?
Kalshi's API serves a CFTC-regulated, dollar-settled exchange; Polymarket's serves an on-chain venue settled in USDC on Polygon. Both are trading-first APIs with limited analytics: Kalshi exposes no sort parameters and volume_24h only, while Polymarket's Gamma API has a handful of sort fields and volume-only stats. Codex covers both venues with one schema, adding rankings, windowed stats, OHLC history, and trader analytics on top. See our full Polymarket API guide for the other side of the comparison.
Get Kalshi and Polymarket data through one API. Sign up for Codex and make your first prediction market query in minutes.

