Skip to Content

useConditions

The useConditions hook is used to fetch Conditions of a specific game.

ℹ️

Hook represents a logic wrapper over TanStack Query’s useQuery hook. Explore TanStack Query docs  to understand what data the hook returns.

Usage

import { useConditions } from '@azuro-org/sdk' const { data, isFetching, error } = useConditions(props)

Props

{ gameId: string | string[] // single game ID or array of game IDs extended?: boolean // opt-in: include new conditions/markets not present in the dictionaries package chainId?: ChainId query?: QueryParameterWithSelect<UseConditionsQueryFnData, TData> // useQuery params }
type UseConditionsQueryFnData = ConditionDetailedData[]
type ChainId = | 137 // Polygon | 80002 // Polygon Amoy | 8453 // Base | 84532 // Base Sepolia
⚠️

gameId property is not the same as id. Each game fetched using useGames hook contains the gameId:

import { useGames } from '@azuro-org/sdk' const { data: gamesData } = useGames() const gameId = gamesData?.games[0]?.gameId const { data } = useConditions({ gameId })
ℹ️

When to enable extended

Optional, defaults to false. When true, the API additionally returns new-generation conditions and outcomes alongside the standard set. Detect a new condition by its first character: conditionId[0] === '5'.

Titles are returned directly in the response. Each condition exposes title (the market name), and each outcome exposes its own title — ConditionDetailedData.title and OutcomeData.title. The toolkit and SDK already handle grouping, sorting, and rendering of new markets out of the box.

  • If your app reads market/outcome metadata only from these hooks’ / utility’s response (no direct use of @azuro-org/dictionaries), enabling the flag is safe — new markets will appear automatically.
  • If your app reads from @azuro-org/dictionaries directly, note that new markets are not in the dictionaries package — their titles live only on the API. Use the title fields returned here.

If you only have a conditionId later (e.g. in a betslip, history, or activity feed) and need its market title, call getConditionsState  — its ConditionStateData now exposes title for the condition and each outcome. The SDK’s useConditionsState  wraps that endpoint.

For new bets, titles also are present in the subgraph.

⚠️

This hook returns everything the game has — hidden conditions and outcomes included.

It filters nothing. A condition or an outcome the provider has taken off the grid comes back flagged hidden: true, so a markets grid rendered straight from useConditions shows markets a bettor is not being offered.

For the list a bettor should see, use useActiveConditions or useActiveMarkets. They wrap this hook and decide visibility on the live value from the feed rather than the fetched one — which is only possible after a condition has been subscribed, so it cannot be decided here, in the fetch.

Reach for useConditions directly when you want the raw feed data: your own query.select, your own grouping or prefetching, or a view that deliberately needs the hidden rows.

ℹ️

The query key is [ 'conditions', chainId, gameId, extended ]. Nothing about visibility is part of it, so one cache entry serves every view of the same game.

ℹ️

Settlement is per-outcome. ConditionState is only ever Active or Stopped — a condition carries no result. Within a single condition, outcomes settle independently: Won, Lost, Canceled (voided, stake refunded) or still Active. Read OutcomeData.state, or isOutcomeSettled, for a result.

Return Value

UseQueryResult<ConditionDetailedData[]>
import { type UseQueryResult } from '@tanstack/react-query' type ConditionDetailedData = { id: string conditionId: string state: ConditionState title: string // market title isExpressForbidden: boolean isPrematchEnabled: boolean isLiveEnabled: boolean /** true for a condition the provider has taken off the grid; optional - the feed doesn't always report it */ hidden?: boolean margin: string outcomes: OutcomeData[] category: ConditionCategory game: { gameId: string sport: { sportId: string } } /** win-only, condition-level list. NOT the per-outcome source of truth - read `OutcomeData.state` */ wonOutcomeIds: string[] sort: `${number}` /** Modern ("5...") conditions only: used for market grouping */ marketId?: string | null marketVarietyId?: string | null } type OutcomeData = { title: string // outcome title outcomeId: string odds: string sort: `${number}` /** Modern ("5...") conditions only: numeric handicap/line value, e.g. "-2.5" / "+2.5" */ point?: string | null hidden: boolean state: OutcomeState } enum ConditionState { Active = 'Active', Stopped = 'Stopped', } enum OutcomeState { Active = 'Active', Canceled = 'Canceled', Stopped = 'Stopped', Won = 'Won', Lost = 'Lost' } type ConditionCategory = | 'correct_score' | 'handicap' | 'handicap_3_way' | 'odd_even' | 'participant_and_total' | 'participant_and_yes_no' | 'participant_slash_participant' | 'players' | 'result' | 'result_or_neither' | 'total' | 'total_3_way' | 'winner' | 'yes_no' | string // extensible — new categories may appear; null when unset | null

Query Options Helper

getUseConditionsQueryOptions lets you build query options outside a component — useful for prefetching, SSR, or composing queries.

import { getUseConditionsQueryOptions } from '@azuro-org/sdk' const options = getUseConditionsQueryOptions({ ...props, chainId }) await queryClient.prefetchQuery(options)
type GetUseConditionsQueryOptionsProps = UseConditionsProps & { chainId: ChainId }