Fetch one NBA team by id
Every table with a single-column primary key exposes a get(id) that returns exactly one row. Here we list one team to get a real id, then fetch it.
1.List one team to borrow an id
A one-row page is enough to get a valid primary key to fetch by.
const teams = (await api.nba.teams.list({ limit: 1 })).teamsThe complete program
Every step as one runnable file. It reads STAT_API_KEY from the environment, and is the same file that ships in the cookbook project for each SDK.
import { StatApi } from '@stat-api/client'
const api = new StatApi() // reads STAT_API_KEY from the environment
// List one team to borrow an id
const teams = (await api.nba.teams.list({ limit: 1 })).teams
// Fetch that team by id
const team = await api.nba.teams.get(teams[0].id)
// Inspect the row
console.log(JSON.stringify(team, null, 2))