STAT-API

Filter MLB games by season

List endpoints accept whitelisted filter parameters. This example resolves the current season from the API (so it survives the annual rollover) and uses it to filter games.

  1. 1. Resolve the current season

    List the seasons table and pick the one with the largest start_year — the example resolves this at run time, so it never goes stale.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/mlb/seasons?limit=200'
  2. 2. Filter games to that season

    Pass season_id as a filter to get only that season's games.

    curl -sS --compressed \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      'https://api.stat-api.com/api/v1/mlb/games?season_id=2026&limit=5'
  3. 3. Print the filtered games

    console.log(JSON.stringify(games, null, 2))