STAT-API
MLB Cookbook

Hello, MLB

Every stat-api client reads its key from the STAT_API_KEY environment variable, so a first program is just: construct the client, call a list endpoint, and look at the rows.

1.List a few teams

list() returns one bounded page wrapped in the list envelope; the rows come back under the table's name.

const teams = (await api.mlb.teams.list({ limit: 3 })).teams

The 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 a few teams
const teams = (await api.mlb.teams.list({ limit: 3 })).teams

// Print what came back
console.log(JSON.stringify(teams, null, 2))