Tutorial · 9 min · endpoints verified 2026-09-20

How to build an MLB live scoreboard

Render team identity, game status, runs and a growing inning table from one canonical MLB match response.

API coverage and endpoint overview: Explore the MLB API

Why this is hard

A baseball score is a sequence, not one number

A useful scoreboard explains how the total formed while keeping the match row authoritative.

  • Inning arrays can grow beyond nine.
  • Scheduled games have no runs yet.
  • A correction can change an earlier inning.
  • Team logos must stay attached to canonical team ids.

Path 1 · recommended

Have your AI agent build it

MCP can resolve MLB games; use the stored-match REST view for its explicit linescore arrays.

1. Connect the MCP server

Add the server in your MCP client and sign in with your Big Balls account. Your client registers itself and handles the token exchange — there is no key to copy.

MCP client configjson
{
  "mcpServers": {
    "bigballs-sports-data": {
      "url": "https://mcp.bigballsdata.com/mcp"
    }
  }
}

2. Tools your agent gets

  • get_matches

    Live, upcoming or historical matches for a sport or league.

  • get_coverage

    Machine-readable map of what we hold and what we do not.

3. Ask for what you want

Paste this at your agent. It is written to make the model check coverage before it designs anything, which is what stops it inventing a field we do not serve.

Prompttext
Build an MLB scoreboard. Check baseball coverage, list MLB games, then call the stored match REST route for inning linescores. Render null innings as unavailable and do not invent a demo score.

What the agent cannot reach

MCP does not expose the stored linescore-specific response. Use REST for the inning table and keep the API key on the server.

Path 2 · hand-coded

Build it yourself

Start with the list response, retain match_id, then render the detail response defensively.

  1. 01

    List MLB games

    Filter explicitly to baseball and MLB so another sport can never enter the board.

    Stored MLB gamesbash
    curl -s "https://api.bigballsdata.com/v1/stored/matches?sport=baseball&league=mlb&limit=20" \
      -H "x-api-key: $BBS_API_KEY"
  2. 02

    Open one game

    Use the returned canonical match id for the detail view.

    Match detailbash
    curl -s "https://api.bigballsdata.com/v1/stored/matches/$MATCH_ID?sport=baseball" \
      -H "x-api-key: $BBS_API_KEY"
  3. 03

    Render every inning

    Use the longer linescore array as the column count; extra innings then work without another layout.

    Linescore columnstypescript
    const innings = Math.max(game.linescore.home.length, game.linescore.away.length);
    const columns = Array.from({ length: innings }, (_, i) => i + 1);

Reference

Every endpoint this tutorial uses

All on the gateway at api.bigballsdata.com. Verified against production on 2026-09-20.

MethodPathReturnsWhy you need itPlan
GET/v1/stored/matches?sport=baseball&league=mlbMLB games with totals and inning arraysPopulates the scoreboard and supplies canonical match ids.Free
GET/v1/stored/matches/:id?sport=baseballOne canonical game and its freshest stored detailDrives the game view without matching on team names.Free

Pricing, honestly

The scoreboard works on Free

Free covers current-season scores and linescores. Higher plans add depth and delivery rather than changing the inning shape.

Free key

jsonjson
Current MLB games and inning arrays.

Solo

jsonjson
More history, higher quota, deeper statistics, and paid betting data.
  • Handle extra innings.
  • Keep null distinct from zero.
  • Cache finished games.

More tutorials

Other build guides

Known gaps

Production checks

Treat availability and corrections as normal states.

  • Revalidate live games on the documented cadence.
  • Stop aggressive polling after final.
  • Preserve canonical team and match ids.

Questions

Does the linescore always have nine entries?
No. Scheduled games can be empty and extra-inning games can exceed nine, so derive the column count from the response.
Should I sum innings for the score?
Display the served total as authoritative and use inning values as the explanation, so later corrections do not create two truths.
How should this update during a game?
Poll the REST response conservatively, display its update time, and slow down after final. This tutorial does not claim an MLB WebSocket surface.

Related APIs

Other APIs you can build with:

Stats reference

Ship the inning board

Start with one real game and make every empty state explicit.