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

How to build an MLB betting model

Resolve the game first, normalize real market prices, and make missing books or historical snapshots part of the model input.

API coverage and endpoint overview: Explore the MLB API

Why this is hard

A baseball model needs prices with identity and time

A number without its game, sportsbook and timestamp cannot be backtested safely.

  • Resolve the canonical match id.
  • Keep moneyline, spread and total distinct.
  • Remove bookmaker margin before comparison.
  • Treat absent history as unavailable.

Path 1 · recommended

Have your AI agent build it

MCP finds games; paid odds calls remain REST-only.

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
Find an MLB game and retain its canonical id. Call the REST odds endpoint, group prices by market and book, normalize implied probabilities, and say when no historical snapshots are loaded.

What the agent cannot reach

MCP has no odds tool. Odds require Edge or above.

Path 2 · hand-coded

Build it yourself

Keep market normalization separate from any predictive model.

  1. 01

    Find a game

    Use the baseball and MLB filters and retain match_id.

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

    Read current markets

    Request odds with the sport filter and group rows by book and market.

    Current MLB oddsbash
    curl -s "https://api.bigballsdata.com/v1/matches/$MATCH_ID/odds?sport=baseball" \
      -H "x-api-key: $BBS_API_KEY"
  3. 03

    Load historical snapshots

    Use the point-in-time series where loaded; never substitute today’s current row for an old price.

    Odds historybash
    curl -s "https://api.bigballsdata.com/v1/odds/historical?match_id=$MATCH_ID" \
      -H "x-api-key: $BBS_API_KEY"
  4. 04

    Remove the vig

    Normalize both sides before comparing a moneyline probability with your model.

    Two-way normalizationtypescript
    const implied = prices.map((decimal) => 1 / decimal);
    const overround = implied.reduce((sum, p) => sum + p, 0);
    const fair = implied.map((p) => p / overround);

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/matches?sport=baseball&league=mlbCanonical MLB games and idsResolves the subject of every market.Free
GET/v1/matches/:id/odds?sport=baseballCurrent moneyline, spread and total marketsSupplies the prices the model evaluates.Edge
GET/v1/odds/historical?match_id=Timestamped odds snapshots where loadedSupports movement and closing-line analysis.Edge

Pricing, honestly

Odds begin at Edge

Free resolves games; Edge supplies current and historical betting markets.

Free key

jsonjson
Match identity, schedule, status and score.

Solo

jsonjson
Moneyline, spread, totals and history where loaded.
  • Check market availability.
  • Retain sportsbook and timestamp.
  • Never claim profitability from an API response.

More tutorials

Other build guides

Known gaps

Model boundaries

Market coverage and prediction quality are separate measurements.

  • Measure historical coverage before backtesting.
  • Use time-safe train/test splits.
  • Track closing price independently from result.

Questions

Are MLB odds available on Free?
No. Game lookup is Free, while current and historical odds require Edge.
Does every game have every market?
No. Inspect the returned books and markets and render unavailable when a market is absent.
Does this tutorial predict winners?
No. It builds a correct market input and normalization layer; model quality remains your responsibility.

Related APIs

Other APIs you can build with:

Build against real MLB markets

Resolve the game for free, then use Edge for prices and history.