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.
{
"mcpServers": {
"bigballs-sports-data": {
"url": "https://mcp.bigballsdata.com/mcp"
}
}
}2. Tools your agent gets
get_matchesLive, upcoming or historical matches for a sport or league.
get_coverageMachine-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.
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.
- 01
Find a game
Use the baseball and MLB filters and retain match_id.
MLB gamesbashcurl -s "https://api.bigballsdata.com/v1/matches?sport=baseball&league=mlb&limit=20" \ -H "x-api-key: $BBS_API_KEY" - 02
Read current markets
Request odds with the sport filter and group rows by book and market.
Current MLB oddsbashcurl -s "https://api.bigballsdata.com/v1/matches/$MATCH_ID/odds?sport=baseball" \ -H "x-api-key: $BBS_API_KEY" - 03
Load historical snapshots
Use the point-in-time series where loaded; never substitute today’s current row for an old price.
Odds historybashcurl -s "https://api.bigballsdata.com/v1/odds/historical?match_id=$MATCH_ID" \ -H "x-api-key: $BBS_API_KEY" - 04
Remove the vig
Normalize both sides before comparing a moneyline probability with your model.
Two-way normalizationtypescriptconst 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.
| Method | Path | Returns | Why you need it | Plan |
|---|---|---|---|---|
| GET | /v1/matches?sport=baseball&league=mlb | Canonical MLB games and ids | Resolves the subject of every market. | Free |
| GET | /v1/matches/:id/odds?sport=baseball | Current moneyline, spread and total markets | Supplies the prices the model evaluates. | Edge |
| GET | /v1/odds/historical?match_id= | Timestamped odds snapshots where loaded | Supports movement and closing-line analysis. | Edge |
Pricing, honestly
Odds begin at Edge
Free resolves games; Edge supplies current and historical betting markets.
Free key
Match identity, schedule, status and score.Solo
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
- How to build a fantasy hockey app
- How to build a fantasy basketball app
- How to build a soccer xG app
- How to build a cricket app
- NFL fantasy football API tutorial
- How to build an NFL scouting tool
- How to build an NFL conditions analytics tool
- NFL betting model API tutorial
- NFL live game center API tutorial
- How to build an NCAAF scoreboard and live game center
- How to build college football rankings and conference standings
- How to build an NCAAF fantasy football app
- How to build an MLB live scoreboard
- How to build a fantasy baseball app
- How to build an MLB pitching dashboard
- How to build an MLB standings dashboard
- How to build a soccer fantasy app
- How to build a soccer betting model
- How to build a soccer live match center
- How to build a soccer scouting tool
- How to build an NCAAF betting model
- How to build an NCAAF conditions analytics tool
- How to build a WNBA live scoreboard
- How to build a WNBA quarter tracker
- How to build a WNBA odds board
- How to build a WNBA schedule browser
- How to build a WNBA team-form tool
- How to build an NCAAB scoreboard
- How to build a March Madness archive
- How to build an NCAAB game-detail view
- How to build an NCAAB team-form dashboard
- How to build an NCAAB head-to-head tool
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.