useActiveMarkets
The useActiveMarkets hook is wrapper over useActiveConditions for groupping active conditions by market.
Usage
import { useActiveMarkets } from '@azuro-org/sdk'
const { data, isFetching, error } = useActiveMarkets(props)Props
{
gameId: string
extended?: boolean // opt-in: include new conditions/markets not present in the dictionaries package
chainId?: ChainId
query?: QueryParameter<ConditionDetailedData[]> // useQuery params
}⚠️
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ℹ️
extended is forwarded to the underlying useActiveConditions call. Set it to true to also surface new-generation markets (conditions whose conditionId[0] === '5') in the grouped result — groupConditionsByMarket already understands the new shape. See the useActiveConditions docs for the full caveat, especially if your app reads @azuro-org/dictionaries directly.
Return Value
UseQueryResult<GameMarkets>import { type UseQueryResult } from '@tanstack/react-query'
type GameMarkets = Market[]
type Market = {
marketKey: string
name: string
description: string
conditions: MarketCondition[]
category: ConditionCategory
type?: 'legacy' | 'v5'
}
type MarketCondition = {
conditionId: string
state: ConditionState
category: ConditionCategory
sort: number
margin: string
hidden?: boolean
isExpressForbidden: boolean
outcomes: MarketOutcome[]
}
type MarketOutcome = {
selectionName: string
odds: number
gameId: string
isExpressForbidden: boolean
isWon?: boolean
hidden: boolean
state: OutcomeState
} & Selection
type Selection = {
conditionId: string
outcomeId: string
}
enum OutcomeState {
Active = 'Active',
Canceled = 'Canceled',
Stopped = 'Stopped',
Won = 'Won',
Lost = 'Lost'
}
// market category, e.g. 'total' | 'handicap' | 'winner' — see groupConditionsByMarket for the full list
type ConditionCategory = string | null