> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Kalshi API

> Access real-time Kalshi prediction market data through the Codex API. Track market prices, trading volumes, events, and trader analytics on the first CFTC-regulated prediction market exchange.

Kalshi is the first CFTC-regulated prediction market exchange in the United States, offering event contracts on topics ranging from politics and economics to weather and technology. Codex will index all Kalshi markets, events, trades, and trader activity, providing comprehensive access to market data through a unified GraphQL API.

<Info>
  Prediction Market data is currently in beta and actively being worked on. Both Polymarket and Kalshi data are available now.

  At least for the time being, these endpoints require a Growth or Enterprise plan. [Learn more](https://dashboard.codex.io/dashboard/billing?utm_source=codex\&utm_medium=docs\&utm_campaign=billing).
</Info>

## Platform Information

| Property        | Value                     |
| --------------- | ------------------------- |
| Platform        | Kalshi                    |
| Protocol Filter | `KALSHI`                  |
| Status          | Live                      |
| Type            | Regulated Exchange (CFTC) |

## Why Use Codex Over the Kalshi API Directly?

|                         | Codex API                                                                                                                                                          | Kalshi API                                                                                                                             |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| **Rate Limits**         | 1,000+ req/s                                                                                                                                                       | \~20 req/s                                                                                                                             |
| **Ranking signals**     | Sort events or markets by trending score, volume, liquidity, open interest, trades, unique traders, or `% change` of any of these at 5m / 1h / 4h / 12h / 24h / 1w | `/events` and `/markets` expose no sort parameter at all. To rank by 24h volume you page through every open event and sort client-side |
| **Time-windowed stats** | Volume, trades, unique traders, liquidity, open interest, and `% change` for each at 5m / 1h / 4h / 12h / 24h / 1w                                                 | `volume_24h_fp` only. No 5m / 1h / 4h / 12h / 1w windows, no trade counts, no liquidity or OI change                                   |
| **Event-level rollups** | Each event response includes aggregated volume, liquidity, OI, trade count, and unique traders across all child markets                                            | Event object is pure metadata. You sum per-market data yourself                                                                        |
| **Filtering**           | Filter events and markets on every stat above plus categories, dates, status, protocol                                                                             | `status`, `series_ticker`, `event_ticker`, `tickers`, and timestamp ranges. No volume, liquidity, or OI filters                        |
| **Cross-venue**         | One query, one schema, one ranking system covering Kalshi and Polymarket (plus future venues)                                                                      | Kalshi only. Integrating Polymarket means a second vendor, second auth, second schema                                                  |

## Understanding Events and Markets

**Events** are collections of related **markets**. For example:

* Event: "Champions League Final 2026"
  * Market 1: "Will Team A win?"
  * Market 2: "Will the score be over 2.5 goals?"
  * Market 3: "Will there be a penalty?"

Use [`filterPredictionEvents`](/api-reference/queries/filterpredictionevents) to find trending high-level topics. Use [`filterPredictionMarkets`](/api-reference/queries/filterpredictionmarkets) to find trending markets.

## ID Formats

Kalshi uses specific ID formats to uniquely identify markets, events, and traders across the platform:

### Market ID

Format: `<marketSlug>:Kalshi`

Example: `KXMVECROSSCATEGORY-S2026A4A05B370DF-F1FBA451AA9:Kalshi`

* `marketSlug`: The Kalshi market identifier (venue market slug)
* `Kalshi`: The protocol identifier

### Event ID

Format: `<eventSlug>:Kalshi`

Example: `KXMVESPORTSMULTIGAMEEXTENDED-S2026350C4EF9BCE:Kalshi`

* `eventSlug`: The Kalshi event identifier (venue event slug)
* `Kalshi`: The protocol identifier

<Note>
  Kalshi uses slug-based identifiers rather than blockchain addresses since it operates as a centralized, CFTC-regulated exchange (not on-chain like Polymarket).
</Note>

## Kalshi-Specific Limitations

<Warning>
  **Trader data is not available for Kalshi**. Due to privacy considerations on Kalshi's regulated exchange, individual trader information is not exposed through their API. This means:

  * No `traderId` filtering is available on any endpoints
  * Trader-specific queries and endpoints cannot be used with Kalshi data
  * Trade data shows aggregate activity but not individual trader identities
  * Trade events show `TRADE` type only (no distinction between BUY/SELL)
</Warning>

## Supported APIs

### Market & Event API

* [Filter Prediction Events](/api-reference/queries/filterpredictionevents) — Query Kalshi events with advanced filtering
* [Filter Prediction Markets](/api-reference/queries/filterpredictionmarkets) — Search and filter Kalshi markets by volume, liquidity, category, and other criteria
* [Get Detailed Event Stats](/api-reference/queries/detailedpredictioneventstats) — Fetch detailed statistics for Kalshi events
* [Get Detailed Market Stats](/api-reference/queries/detailedpredictionmarketstats) — Retrieve comprehensive trading metrics for any Kalshi market
* [Get Event Price Bars](/api-reference/queries/predictioneventbars) — Retrieve event-level price history for charting
* [Get Market Price Bars](/api-reference/queries/predictionmarketbars) — Fetch OHLC price data for Kalshi markets

### Trading & Activity API

* [Get Prediction Trades](/api-reference/queries/predictiontrades) — Query trade history and aggregate trading activity on Kalshi (no individual trader data)

### Market Discovery API

* [Get Prediction Categories](/api-reference/queries/predictioncategories) — Browse Kalshi categories (Politics, Economics, Weather, etc.)

## Example Queries (Available Soon)

### Find Trending Kalshi Events

```graphql theme={null}
{
  filterPredictionEvents(
    filters: {
      protocol: KALSHI
      status: OPEN
    }
    rankings: [{ attribute: trendingScore24h, direction: DESC }]
    limit: 10
  ) {
    count
    results {
      event {
        question
        description
      }
      marketCount
      volumeUsd24h
      trendingScore24h
    }
  }
}
```

### Find Top Kalshi Markets by 24h Volume

```graphql theme={null}
{
  filterPredictionMarkets(
    filters: {
      protocol: KALSHI
      status: OPEN
    }
    rankings: [{ attribute: volumeUsd24h, direction: DESC }]
    limit: 10
  ) {
    count
    results {
      id
      eventLabel
      protocol
      market {
        question
        label
        status
        protocol
      }
      volumeUsd24h
      liquidityUsd
      trades24h
      uniqueTraders24h
      outcome0 {
        label
        lastPriceUsd
      }
      outcome1 {
        label
        lastPriceUsd
      }
    }
  }
}
```

### Find Kalshi Markets in Economics Category

```graphql theme={null}
{
  filterPredictionMarkets(
    filters: {
      protocol: KALSHI
      status: OPEN
      categories: ["economics"]
    }
    rankings: [{ attribute: volumeUsd24h, direction: DESC }]
    limit: 20
  ) {
    count
    results {
      id
      eventLabel
      market {
        question
      }
      categories
      volumeUsd24h
      liquidityUsd
      outcome0 {
        label
        lastPriceUsd
      }
      outcome1 {
        label
        lastPriceUsd
      }
    }
  }
}
```

### Get Price History for a Market

```graphql theme={null}
{
  predictionMarketBars(
    input: {
      marketId: "KXMVECROSSCATEGORY-S2026A4A05B370DF-F1FBA451AA9:Kalshi"
      resolution: hour1
      from: 1772665600
      to: 1773270400
    }
  ) {
    marketId
    bars {
      t
      volumeUsd
      trades
      uniqueTraders
      outcome0 {
        priceUsd {
          o
          h
          l
          c
        }
      }
      outcome1 {
        priceUsd {
          o
          h
          l
          c
        }
      }
    }
  }
}
```

## Try It in the Explorer

Test any Kalshi query directly in the [Codex GraphQL Explorer](/explore).

## Recipes

Step-by-step guides for building with prediction market data:

<CardGroup cols={2}>
  <Card title="Discover Prediction Markets" icon="magnifying-glass" href="/recipes/predictions/discover-markets">
    Browse categories, trending events, and filter markets.
  </Card>

  <Card title="Prediction Charts" icon="chart-line" href="/recipes/predictions/charts">
    Outcome probability charts, multi-market comparisons, and OHLC data.
  </Card>

  <Card title="Prediction Event Dashboard" icon="table-columns" href="/recipes/predictions/event-dashboard">
    Build a complete event detail page with real-time data.
  </Card>
</CardGroup>

## Related Resources

* [Supported Prediction Markets Overview](/prediction-markets) — All supported platforms
* [Polymarket API](/prediction-markets/polymarket) — Live prediction market data
