useGames
The useGames hook is used to fetch pre-match and live games.
ℹ️
Hook represents a logic wrapper over TanStack Query’s useQuery hook. Explore TanStack Query docs to understand what data the hook returns.
Usage
import { useGames } from '@azuro-org/sdk'
const { data, isFetching, error } = useGames(props)Props
{
filter?: {
sportHub?: SportHub // returns games from specific hub
sportSlug?: string // returns games from specific sport
sportIds?: Array<string | number> // returns games from specific sport IDs
leagueSlug?: string // returns games from specific league (single value)
}
page?: number // page number (1-based), default: 1
perPage?: number // items per page, default: 100
orderBy?: GameOrderBy // default: GameOrderBy.StartsAt - orders rows by passed rule
orderDir?: OrderDirection // order direction: asc, desc
isLive?: boolean // if `true`, the hook will retrieve live games
chainId?: ChainId
query?: QueryParameter<GetGamesByFiltersResult> // useQuery params
}type ChainId =
| 100 // Gnosis
| 137 // Polygon
| 80002 // Polygon Amoy
| 88888 // Chiliz
| 88882 // Chiliz Spicy
| 8453 // Base
| 84532 // Base Sepolia
enum SportHub {
Sports = 'sports',
Esports = 'esports',
Unique = 'unique'
}Return Value
UseQueryResult<GetGamesByFiltersResult>import { type UseQueryResult } from '@tanstack/react-query'
type GetGamesByFiltersResult = {
games: GameData[]
page: number
perPage: number
total: number
totalPages: number
}
type GameData = {
gameId: string
slug: string
title: string
startsAt: number
state: GameState
sportId: string
sportSlug: string
sportName: string
leagueId: string
leagueSlug: string
leagueName: string
countrySlug: string
countryName: string
participants: Array<{
image?: string
name: string
}>
}