Tutorial · 11 min · endpoints verified 2026-09-20
How to build a fantasy baseball app
Resolve one player identity, separate batting from pitching, and score only the fields the API actually serves.
API coverage and endpoint overview: Explore the MLB API
Why this is hard
Fantasy scoring starts with identity and role
A player can have batting and pitching fields, and the populated key set varies by row.
- Find the canonical player id first.
- Do not treat a missing stat as zero.
- Keep batting and pitching formulas separate.
- Use game logs for recency rather than rewriting season totals.
Path 1 · recommended
Have your AI agent build it
MCP can find players and fetch their aggregate stats.
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
find_playersFind canonical player IDs by name for use with player-stat tools.
get_player_statsPer-player career or per-season totals and per-game rates.
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.
Build a fantasy baseball board. Find each canonical MLB player, fetch baseball player stats, separate hitters and pitchers by served fields, and show unavailable for missing values.What the agent cannot reach
MCP does not expose game-log or rolling-stat routes. Use REST for recency and do not join ambiguous names.
Path 2 · hand-coded
Build it yourself
Resolve identity once, then retain that id through every player view.
- 01
Find the player
Search the player catalogue and require a canonical id before enabling detail.
Player lookupbashcurl -s "https://api.bigballsdata.com/v1/players?sport=baseball&name=judge" \ -H "x-api-key: $BBS_API_KEY" - 02
Read season stats
The response is a field map; inspect keys before applying a scoring rule.
Player statsbashcurl -s "https://api.bigballsdata.com/v1/players/$PLAYER_ID/stats?sport=baseball" \ -H "x-api-key: $BBS_API_KEY" - 03
Add recent form
Use the game log or rolling windows to show recency separately from season production.
Rolling statsbashcurl -s "https://api.bigballsdata.com/v1/players/$PLAYER_ID/rolling-stats?sport=baseball" \ -H "x-api-key: $BBS_API_KEY"
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/players?sport=baseball&name= | Canonical player candidates | Prevents a display-name join from becoming product identity. | Free |
| GET | /v1/players/:id/stats?sport=baseball | Available batting and pitching season fields | Supplies the season scoring inputs. | Free |
| GET | /v1/players/:id/game-log?sport=baseball | Per-game player lines | Supports trend charts without reinterpreting aggregates. | Free |
| GET | /v1/players/:id/rolling-stats?sport=baseball | Rolling player windows | Adds recent form for a production fantasy tool. | Solo |
Pricing, honestly
Free proves the scoring model
Free supplies identity and core player statistics. Solo adds production depth such as rolling form and player media where stored.
Free key
Player lookup, season stats and game logs.Solo
Rolling form, media, and the five-season Solo product entitlement.- Keep the formula visible.
- Score only populated fields.
- Use an initials fallback for absent headshots.
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 an MLB pitching dashboard
- How to build an MLB betting model
- 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
Fantasy boundaries
A useful board does not hide missing context.
- Injury reports remain coming soon in the coverage manifest.
- Not every historical game has per-player lines.
- Pitch-level data is not a public endpoint yet.
Questions
- Are batting and pitching fields fixed?
- No. The response is a populated field map, so clients must inspect the returned keys.
- Can I use player names as ids?
- No. Resolve and retain the canonical player id; same-name records are not safe joins.
- Are headshots guaranteed?
- No. Use the served first-party URL when present and an honest initials fallback when absent.