This is a web scraper that collects historical MLB betting odds from SportsBookReview, and saves it in JSON format. The data contains information about Point Spread, Money Line, and Totals odds from multiple sportsbooks, including DraftKings, Bet365, and FanDuel. The repo also contains a downloadable dataset (76 MB) for all odds in the date range 2021-03-20 to 2025-08-16.
Paste the commands line by line into terminal:
- Clone the repository
git clone https://github.com/ArnavSaraogi/mlb-odds-scraper
cd mlb-odds-scraper- Set up virtual environment and install requirements
python3 -m venv venv
source venv/bin/activate # on Windows, the command is venv\Scripts\activate- Install requirements
pip install -r requirements.txtOnce you have the directory set up, use terminal to run:
python scraper.py <start_date> <end_date>There are also some optional flags:
| Flag | Description |
|---|---|
-t, --type |
The type of odds (moneyline, pointspread, totals) that you want to retrieve; enter them separated by a space. Default: moneyline |
-c, --concurrent |
How many HTTP requests the scraper can make at once. Default: 5 |
-f, --fast |
Decreases the sleep time between requests, making the scraping faster |
-o, --output |
The filename of the JSON output. Default: mlb_odds.json |
So, an example of running the app is:
python scraper.py 2021-03-20 2025-08-16 -t moneyline pointspread -c 8 -o my_data.json -fThe data is organized by date. Each date contains a list of games, with game details and sportsbook odds. Here's what the structure looks like:
{
"2021-04-01": [
{
"gameView": {
"startDate": "2021-04-01T17:05:00+00:00",
"awayTeam": {
"fullName": "Toronto Blue Jays",
"shortName": "TOR"
},
"awayTeamScore": 3,
"homeTeam": {
"fullName": "New York Yankees",
"shortName": "NYY"
},
"homeTeamScore": 2,
"gameStatusText": "Final (10)",
"venueName": "Yankee Stadium",
"gameType": "R"
},
"odds": {
"moneyline": [
{
"sportsbook": "fanduel",
"openingLine": { "homeOdds": -188, "awayOdds": 155 },
"currentLine": { "homeOdds": -200, "awayOdds": 168 }
},
{
"sportsbook": "draftkings",
"openingLine": { "homeOdds": -175, "awayOdds": 148 },
"currentLine": { "homeOdds": -195, "awayOdds": 165 }
}
],
"pointspread": [
{
"sportsbook": "fanduel",
"openingLine": {
"homeOdds": 122,
"awayOdds": -144,
"homeSpread": -1.5,
"awaySpread": 1.5
},
"currentLine": {
"homeOdds": 100,
"awayOdds": -120,
"homeSpread": -1.5,
"awaySpread": 1.5
}
}
],
"totals": [
{
"sportsbook": "fanduel",
"openingLine": { "overOdds": -106, "underOdds": -114, "total": 8 },
"currentLine": { "overOdds": -122, "underOdds": 100, "total": 7.5 }
}
]
}
}
]
}- It seems that historical odds data is reliably available on SportsBookReview starting 2019-05-03, so I recomend scraping from that as the earliest
- The reason --fast is a flag (and not just the default) is because SportsBookReview may have anti-bot protections and block you if you're sending too many requests too quickly.
- The gameType field in gameView is taken from the MLB API for the specific game. It specifies what type of game it is:
- "R": Regular Season
- "S": Spring Training
- "E": Exhibition
- "A": All-Star Game
- "D": Division Series
- "F": First Round (Wild Card)
- "L": League Championship
- "W": World Series
- Make sure your computer doesn't sleep while you're running the script, otherwise the scraper will pause/fail.
- https://github.com/flancast90/sportsbookreview-scraper: this is another SportBookReview scraper, which also supports sports beyond just MLB. However, it doesn't have odds from different sportsbooks, and seems to just have an aggregated moneyline odds.
- Different APIs that provide sports odds. The most popular ones include The Odds API, SportsDevs, and API Football. However, free tiers are limited and some don't even provide historical data in the free.