Skip to Content
Developer HubToolkitFeedgetGamesByFilters

getGamesByFilters

Fetches games by applying various filters such as sport, league, or game state. Returns paginated results ideal for building sport/country/league listing pages.

Usage

import { GameState, getGamesByFilters } from '@azuro-org/toolkit' const games = await getGamesByFilters({ chainId: 137, state: GameState.Prematch, page: 2, perPage: 50, })

Props

type GetGamesByFiltersParams = { chainId: ChainId state: GameState.Live | GameState.Prematch sportHub?: SportHubSlug // 'sports' or 'esports' sportIds?: string | number | (string | number)[] sportSlug?: string leagueSlug?: string orderBy?: GameOrderBy orderDir?: OrderDirection /** 1-based, default: 1 */ page?: number /** 1-based, default: 100 */ perPage?: number }
type SportHubSlug = 'sports' | 'esports' enum GameOrderBy { StartsAt = 'startsAt', Turnover = 'turnover' } enum OrderDirection { Asc = 'asc', Desc = 'desc' }

Return Value

type GetGamesByFiltersResult = { games: GameData[] page: number perPage: number total: number totalPages: number }
type GameData = { id: string gameId: string slug: string title: string /** to align with the legacy from the subgraph, it's the unix timestamp in seconds, e.g. `"1771707600"` */ startsAt: string state: GameState turnover: string sport: { sportId: string slug: string name: string sporthub: { id: string slug: SportHubSlug } } league: { id?: string slug: string name: string } country: { id?: string slug: string name: string } participants: GameParticipant[] } type GameParticipant = { image: string | null | undefined name: string }
enum GameState { Finished = 'Finished', Live = 'Live', Prematch = 'Prematch', Stopped = 'Stopped', Canceled = 'Canceled', }
Last updated on