How do I get MLB scores and the schedule in Python?
MLB results for a date range with runs by team and the winner. Eight postseason games were final from October 6 to 10.
Code verified November 18, 2026. One call to get_games, 2 credits.
The call
Dates are US Eastern. Use date for one day, team for one club, season_type for regular or postseason, and status final or scheduled. get_schedule lists the next days. Pass league: "ncaabase" for college baseball.
import requests
import pandas as pd
API_KEY = "YOUR_API_KEY"
resp = requests.post(
"https://mcp.fastballapi.com/v1/get_games",
headers={"x-api-key": API_KEY},
json={
"from": "2026-10-06",
"to": "2026-10-10",
"status": "final",
},
timeout=60,
)
resp.raise_for_status()
data = resp.json()["data"]
games = pd.json_normalize(data["games"])
games["winner"] = games.apply(lambda g: g["home.abbrev"] if g["home.runs"] > g["away.runs"] else g["away.abbrev"], axis=1)
print(len(games), "final games,", games["date"].min(), "to", games["date"].max())
print(games[["date", "season_type", "away.abbrev", "away.runs", "home.abbrev", "home.runs", "winner"]].to_string(index=False))
Replace YOUR_API_KEY with a key from your dashboard. Python needs requests and pandas (pip install requests pandas). JavaScript runs on Node 18 or newer, or in the browser.
Or use the official client: pip install fastballapi
What comes back
The data object of the response, trimmed to the first rows. Every field is real output from the run above.
{
"games": [
{
"game_id": "401907994",
"season": 2026,
"season_type": "postseason",
"date": "2026-10-10",
"starts_at": "2026-10-11T00:00:00.000Z",
"status": "final",
"home": {
"team_id": "5",
"abbrev": "CLE",
"name": "Cleveland Guardians",
"runs": 2,
"hits": 6,
"errors": 0
},
"away": {
"team_id": "4",
"abbrev": "CHW",
"name": "Chicago White Sox",
"runs": 0,
"hits": 3,
"errors": 1
},
"innings": 9,
"extra_innings": false,
"venue": "Progressive Field",
"city": "Cleveland",
"attendance": 36889
},
{
"game_id": "401907993",
"season": 2026,
"season_type": "postseason",
"date": "2026-10-08",
"starts_at": "2026-10-09T00:00:00.000Z",
"status": "final",
"home": {
"team_id": "4",
"abbrev": "CHW",
"name": "Chicago White Sox",
"runs": 5,
"hits": 8,
"errors": 0
},
"away": {
"team_id": "5",
"abbrev": "CLE",
"name": "Cleveland Guardians",
"runs": 9,
"hits": 10,
"errors": 0
},
"innings": 9,
"extra_innings": false,
"venue": "Rate Field",
"city": "Chicago",
"attendance": 39920
},
"...6 more"
],
"count": 8,
"next_offset": null
}What to do next
- get_schedule (2 credits). The next days of games, with lines where posted.
- get_game (5 credits). The box score for one game from this list.
More guides
The same guide for other sports
- PuckAPI: How do I get today's NHL schedule and scores in Python?
- EndzoneAPI: How do I get NFL scores and the schedule for a week in Python?
- FighterAPI: How do I get the upcoming UFC fight schedule in Python?
- StrikerAPI: How do I get Premier League scores and fixtures in Python?
- DunkAPI: How do I get today's NBA schedule and scores in Python?
- AcesAPI: How do I get set-by-set tennis scores for a tournament in Python?
- BirdieAPI: How do I get the PGA Tour schedule in Python?
Rather ask Claude? 20 free Claude skills call these endpoints for you.
Start with 500 free credits every month
No card. REST or MCP.