> ## 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.

# detailedPredictionEventStats

> Returns windowed and all-time stats for a prediction event. detailedPredictionEventStats query reference: arguments and response fields.

> [!NOTE]
>
> At least for the time being, this endpoint requires a Growth or Enterprise plan. [Learn more](https://dashboard.codex.io/dashboard/billing?utm_source=codex\&utm_medium=docs\&utm_campaign=billing).

## GraphQL

```
type Query {
  # Requires a Growth or Enterprise plan.
  detailedPredictionEventStats(
    input: DetailedPredictionEventStatsInput!
  ): DetailedPredictionEventStats
}

enum PredictionProtocol {
  POLYMARKET
  KALSHI
}

enum PredictionEventStatus {
  OPEN
  SUSPENDED
  RESOLVED
  CANCELLED
  PENDING
}

type PredictionResolution {
  result: String
  source: String
}

type PredictionSubSubcategory {
  name: String!
  slug: String!
}

type PredictionSubcategory {
  name: String!
  slug: String!
  subcategories: [PredictionSubSubcategory!]
}

type PredictionCategory {
  name: String!
  slug: String!
  subcategories: [PredictionSubcategory!]
}

enum PredictionMetadataType {
  SPORTS
}

type SportsTeam {
  abbreviation: String!
  altAbbreviations: [String!]
  name: String
  league: String
  logo: String
  alias: String
  color: String
  providerId: Int
  isHome: Boolean
}

enum SportsTimezone {
  UTC
}

type KalshiSportsTickerComponents {
  rawTicker: String!
  seriesPrefix: String!
  seriesSport: String
  teamTailRaw: String
  homeAbbreviation: String
  awayAbbreviation: String
}

type DecomposedVenueTicker {
  kalshiSports: KalshiSportsTickerComponents
}

type SportsEventEnrichedMetadata {
  league: String
  teams: [SportsTeam!]
  gameStartDate: String
  gameStartTime: String
  gameStartTimeSeconds: Int
  gameStartTimezone: SportsTimezone
  decomposedVenueTicker: DecomposedVenueTicker
}

type PredictionEventEnrichedMetadata {
  metadataType: PredictionMetadataType!
  sports: SportsEventEnrichedMetadata
}

type PredictionEvent {
  id: String!
  protocol: PredictionProtocol!
  venueEventId: String!
  venueSeriesId: String
  status: PredictionEventStatus!
  question: String!
  url: String!
  rulesPrimary: String!
  rulesSecondary: String
  tags: [String!]!
  opensAt: Int!
  closesAt: Int
  resolvesAt: Int
  resolvedAt: Int
  resolution: PredictionResolution
  imageLargeUrl: String
  imageThumbUrl: String
  imageSmallUrl: String
  createdAt: Int!
  updatedAt: Int!
  networkId: Int
  marketIds: [String!]
  categories: [PredictionCategory!]
  enrichedMetadata: PredictionEventEnrichedMetadata
}

type SportsMarketEnrichedMetadata {
  sportsMarketType: String
  league: String
  teams: [SportsTeam!]
  gameStartDate: String
  gameStartTime: String
  gameStartTimeSeconds: Int
  gameStartTimezone: SportsTimezone
}

type PredictionMarketEnrichedMetadata {
  metadataType: PredictionMetadataType!
  sports: SportsMarketEnrichedMetadata
}

type PredictionMarket {
  id: String!
  protocol: PredictionProtocol!
  venueMarketId: String!
  venueMarketSlug: String
  eventId: String
  venueEventId: String
  question: String
  label: String
  suggestedLabel: String
  eventLabel: String
  rules: String
  rules2: String
  venueOutcomeIds: [String!]!
  outcomeIds: [String!]!
  outcomeLabels: [String!]
  resolution: PredictionResolution
  imageLargeUrl: String
  imageThumbUrl: String
  imageSmallUrl: String
  createdAt: Int
  updatedAt: Int
  opensAt: Int
  closesAt: Int
  resolvesAt: Int
  resolvedAt: Int
  observedAt: Int!
  networkId: Int
  exchangeAddress: String
  categories: [PredictionCategory!]
  winningOutcomeId: String
  enrichedMetadata: PredictionMarketEnrichedMetadata
}

type PredictionLifecycleStats {
  ageSeconds: Int!
  expectedLifespanSeconds: Int
  timeToResolutionSeconds: Int
  isResolved: Boolean!
  winningOutcomeId: String
}

type CurrencyValuePair {
  usd: String!
  ct: String!
}

type WindowedPredictionEventCoreStats {
  volume: CurrencyValuePair!
  trades: Int!
}

type WindowedPredictionEventBuySellStats {
  buyVolume: CurrencyValuePair!
  sellVolume: CurrencyValuePair!
}

type WindowedPredictionEventUniqueTraderStats {
  uniqueTraders: Int!
}

type CurrencyOHLC {
  open: CurrencyValuePair!
  close: CurrencyValuePair!
  low: CurrencyValuePair!
  high: CurrencyValuePair!
}

type WindowedPredictionEventLiquidityStats {
  liquidity: CurrencyOHLC!
}

type WindowedPredictionEventOpenInterestStats {
  openInterest: CurrencyOHLC!
}

type WindowedPredictionEventChangeStats {
  volumeChange: Float!
  tradesChange: Float!
  buyVolumeChange: Float
  sellVolumeChange: Float
  uniqueTradersChange: Float
  liquidityChange: Float
  openInterestChange: Float
}

type PredictionEventWindowScores {
  trending: Float!
  relevance: Float!
  competitive: Float!
}

type WindowedPredictionAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type EnhancedWindowedPredictionEventStats {
  start: Int!
  end: Int!
  lastTransactionAt: Int!
  core: WindowedPredictionEventCoreStats!
  buySell: WindowedPredictionEventBuySellStats
  uniqueTraders: WindowedPredictionEventUniqueTraderStats
  liquidity: WindowedPredictionEventLiquidityStats
  openInterest: WindowedPredictionEventOpenInterestStats
  statsChange: WindowedPredictionEventChangeStats!
  scores: PredictionEventWindowScores!
  allTimeStats: WindowedPredictionAllTimeStats!
}

type DetailedPredictionStatsScores {
  score5m: Float
  score1: Float
  score4: Float
  score12: Float
  score24: Float
  score1w: Float
}

type PredictionEventAllTimeStats {
  volume: CurrencyValuePair!
  venueVolume: CurrencyValuePair
}

type DetailedPredictionEventStats {
  eventId: String!
  predictionEvent: PredictionEvent!
  predictionMarkets: [PredictionMarket!]!
  lastTransactionAt: Int!
  lifecycle: PredictionLifecycleStats!
  statsMin5: EnhancedWindowedPredictionEventStats
  statsHour1: EnhancedWindowedPredictionEventStats
  statsHour4: EnhancedWindowedPredictionEventStats
  statsHour12: EnhancedWindowedPredictionEventStats
  statsDay1: EnhancedWindowedPredictionEventStats
  statsWeek1: EnhancedWindowedPredictionEventStats
  trendingScores: DetailedPredictionStatsScores!
  relevanceScores: DetailedPredictionStatsScores!
  allTimeStats: PredictionEventAllTimeStats!
}

enum PredictionStatsDuration {
  week1
  day1
  hour12
  hour4
  hour1
  min5
}

input DetailedPredictionEventStatsInput {
  eventId: String!
  timestamp: Int
  durations: [PredictionStatsDuration!]
  bucketCount: Int
}
```

## Example: Get detailed stats for a specific event

[Test this query in the Explorer →](https://docs.codex.io/explore.md)

```graphql theme={null}
{
  detailedPredictionEventStats(
    input: {
      eventId: "67284:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137"
    }
  ) {
    eventId
    predictionEvent {
      protocol
      question
      closesAt
      resolvedAt
      createdAt
    }
    statsHour1 {
      core {
        volume {
          usd
        }
      }
      uniqueTraders {
        uniqueTraders
      }
    }
    statsHour4 {
      core {
        volume {
          usd
        }
      }
    }
    statsDay1 {
      core {
        volume {
          usd
        }
      }
      liquidity {
        liquidity {
          close {
            usd
          }
        }
      }
      uniqueTraders {
        uniqueTraders
      }
    }
    allTimeStats {
      volume {
        usd
      }
    }
  }
}
```

```json Example Response theme={null}
{
  "data": {
    "detailedPredictionEventStats": {
      "eventId": "67284:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137",
      "predictionEvent": {
        "protocol": "POLYMARKET",
        "question": "Fed decision in March?",
        "closesAt": 1773792000,
        "resolvedAt": null,
        "createdAt": 1768590204
      },
      "statsHour1": {
        "core": {
          "volume": {
            "usd": "7124"
          }
        },
        "uniqueTraders": {
          "uniqueTraders": 62
        }
      },
      "statsHour4": {
        "core": {
          "volume": {
            "usd": "2835595"
          }
        }
      },
      "statsDay1": {
        "core": {
          "volume": {
            "usd": "15371853"
          }
        },
        "liquidity": {
          "liquidity": {
            "close": {
              "usd": "32228389"
            }
          }
        },
        "uniqueTraders": {
          "uniqueTraders": 2553
        }
      },
      "allTimeStats": {
        "volume": {
          "usd": "175071520"
        }
      }
    }
  }
}
```

### Usage Guidelines

* The `eventId` format varies by platform:
  * **Polymarket**: `<eventSlug>:Polymarket:<exchangeAddress>:<networkId>` (e.g., `67284:Polymarket:0xc5d563a36ae78145c45a50134d48a1215220f80a:137`)
  * **Kalshi**: `<eventSlug>:Kalshi` (e.g., `KXMVESPORTSMULTIGAMEEXTENDED-S2026350C4EF9BCE:Kalshi`)
* Query only the time windows you need (statsMin5, statsHour1, statsHour4, etc.) to reduce response size
* Event stats aggregate data from **all markets** within the event - use [`detailedPredictionMarketStats`](https://docs.codex.io/api-reference/queries/detailedpredictionmarketstats) for individual market analysis
* Each windowed stat includes `core` (volume, trades), `uniqueTraders`, `liquidity`, `openInterest`, `statsChange` (percentage changes vs previous window), `scores`, and `allTimeStats` (aggregate snapshot at window end)
* Use [`filterPredictionEvents`](https://docs.codex.io/api-reference/queries/filterpredictionevents) to find eventIds - you can't query this endpoint without one
* For real-time updates, use the [`onDetailedPredictionEventStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedpredictioneventstatsupdated) subscription

### Understanding Scores

Each time window includes three scores that help rank and filter events:

* **`trending`** - Measures what's "heating up" - prioritizes growth velocity over absolute size (a small event with 10x volume growth scores higher than a large event with flat volume)
* **`relevance`** - Measures what "matters" - based on absolute size and capital at stake, with no growth multipliers (large, established events rank high even if quiet)
* **`competitive`** - Measures genuine uncertainty - higher when prices are near 50%, trading is balanced on both sides, and there's active price discovery

### Troubleshooting Tips

> [accordion] What's the difference between event stats and market stats?
>
> Events can contain multiple markets. Event stats aggregate all volume, traders, and liquidity across those markets. Use [`detailedPredictionMarketStats`](https://docs.codex.io/api-reference/queries/detailedpredictionmarketstats) for stats on a specific market within an event.

> [accordion] How do I find event IDs?
>
> Use [`filterPredictionEvents`](https://docs.codex.io/api-reference/queries/filterpredictionevents) to search for events, or get the `eventId` from any market query.

> [accordion] Can I get historical time-series data?
>
> Use [`predictionEventBars`](https://docs.codex.io/api-reference/queries/predictioneventbars) for OHLC bars over time. This query only returns current windowed snapshots.

### Related Recipes

* [Prediction Event Dashboard](https://docs.codex.io/recipes/predictions/event-dashboard.md): Build a full event detail page using this endpoint for metadata and stats


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.