Back to Blog
Tutorials2026-04-16

Build an MLB Standings Tracker

Create a real-time division standings board using the Baseball API standings endpoint.

Project Overview

In this tutorial, you'll build a standings tracker that displays MLB division standings with wins, losses, winning percentage, and games behind. We'll fetch data from the Baseball API and create a clean, responsive UI.

Prerequisites

  • An API4Sports API key with Baseball access
  • Basic knowledge of JavaScript/TypeScript
  • Node.js or a frontend framework (Vue, React, etc.)

Step 1: Fetch League Data

First, get the league ID for MLB (or any league you want to track).

Step 2: Fetch Standings

Use the league ID to fetch current standings, grouped by division.

Step 3: Data Structure

The standings endpoint returns teams grouped by division with these fields:

  • position - Current rank in division
  • team_name - Full team name
  • team_logo - Team logo URL
  • wins - Total wins
  • losses - Total losses
  • pct - Winning percentage (0.623 = 62.3%)
  • gb - Games behind division leader ('-' for first place)

Step 4: Create the UI Component

Here's a Vue 3 component example for displaying standings:

Step 5: Add Caching

Standings don't change frequently. Cache results for 15-30 minutes to reduce API calls.

Step 6: Add Division Filters

Let users filter by American League or National League:

  • AL divisions: AL East, AL Central, AL West
  • NL divisions: NL East, NL Central, NL West
  • Show all 6 divisions or filter by conference

Enhancement Ideas

  • Add wild card standings calculation
  • Show team streaks (W5, L3) from games endpoint
  • Display last 10 games record
  • Add playoff clinch/elimination magic numbers
  • Compare standings across multiple seasons

API Rate Limits

Monitor your daily request limit. For standings, refreshing every 15-30 minutes is sufficient since standings only change after games complete.