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 | bigint | string[] | bigint[] // single game ID or array of game IDs onlyActiveOrStopped?: boolean // if true, returns only active or stopped conditions 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 { useGame } from '@azuro-org/sdk' const { data: games } = useGames() const gameId = 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.

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 stopped secondary conditions; consumed by useConditionState / useConditionsState */ hidden?: boolean margin: string outcomes: OutcomeData[] game: { gameId: string sport: { sportId: string } } 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 } enum ConditionState { Created = 'Created', Active = 'Active', Stopped = 'Stopped', Resolved = 'Resolved', Canceled = 'Canceled', Paused = 'Paused' }

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 }
Last updated on