How to Scrape Sportsbook Odds in Python (and When Not To)
Scraping sportsbook odds is easy to start and hard to keep matched. The SmartStake Odds API serves 85+ books in one schema, with no scraper to maintain.

To scrape sportsbook odds, you read the JSON a sportsbook's site loads in your browser, then turn every book's shape into one: one team name, one market, one price format. The fetching takes an afternoon. The matching, and keeping it matched, is the real work.
Before you build, know two things. Most sportsbooks' terms forbid scrapers. And the SmartStake Odds API already serves 85+ sportsbooks, exchanges and prediction markets in one schema, so for prices across books kept current, one API key is the shorter build.
Here is why matching is the hard part. Four illustrative books return the same moneyline in four shapes. Switch each normalizing step off, then change Book C's site, and watch prices fall off your line.
Try It: Match Four Scraped Books
Four scraped books, one moneyline: Celtics at Knicks
Each book's site returns the same game in its own shape. Switch each normalizing step on or off, then change Book C's site, and watch which prices make it onto one line.
American text, American numbers and fractions
"BOS Celtics", "Celtics" and "Boston" to one team
"Match Winner", "Money Line" and "ML" to one market
It renames one field overnight
{"event": "BOS Celtics @ NY Knicks", "market": "Moneyline",
"outcomes": [{"name": "BOS Celtics", "price": "+124"},
{"name": "NY Knicks", "price": "-146"}]}{"ev": "New York Knicks v Boston Celtics", "mkt": "Match Winner",
"sel": [{"team": "New York Knicks", "odds": 1.69},
{"team": "Boston Celtics", "odds": 2.30}]}{"fixture": "Celtics at Knicks", "bet_type": "Money Line",
"runners": [{"runner": "Celtics", "frac": "5/4"},
{"runner": "Knicks", "frac": "8/13"}]}{"game": "Boston - New York", "type": "ML",
"away": {"team": "Boston", "american": 128},
"home": {"team": "New York", "american": -152}}On the SmartStake Odds API every book's quote on this line shares one line id, with sides awayteam and hometeam and prices in the format you ask for:
m~evt_01M5B7Q2KXN4T8RZ3D6WFHJ9CE~basketball_moneyline~none~none~0.0Illustrative books, payloads and prices, not real sportsbook data. Prices are converted with SmartStake's own odds converters. An arbitrage only holds if both bets are accepted at these prices, and any single bet can win or lose.
With every step on, all 4 books land on one line. The best Celtics price is +130 and the best Knicks price is −145, both at Book B, for a combined implied probability of 102.65%: no arbitrage, but a real best price on each side.
Switch off Map market names and only Book A is left, because Book B calls the market "Match Winner" and Books C and D write "Money Line" and "ML". Your best prices fall to +124 and −146, and you never see the +130.
Now turn the market step back on and flip Book C changes its site. One renamed field, runners to selections, and Book C drops out until someone fixes the parser. Multiply that by every book you scrape and every season they redesign.
How Sportsbook Sites Load Their Odds
A modern sportsbook page is an app. The HTML arrives nearly empty, then the page calls the book's own endpoints for events, markets and prices, and draws them. That is why parsing the HTML rarely works and reading the JSON does.
To see it, open a book's odds page with your browser's developer tools:
- Open the Network tab and filter by Fetch/XHR.
- Reload the page and click a game.
- Look for responses full of team names and prices. That JSON is what a scraper reads.
What you find is undocumented. Nobody promises the field names, the URL or the response shape will be the same tomorrow, and several things sit between your server and that JSON:
- Geolocation. Most U.S. books run state by state and check where a request comes from. A scraper on a server outside a legal state often sees no odds at all.
- State sites. The same book can serve different markets and prices in New Jersey and in Ohio, from different endpoints.
- Bot protection. Many books screen out automated traffic. Getting around it is exactly what their terms forbid, so this guide does not cover it.
Many open source odds scrapers read odds comparison sites rather than the books themselves. That adds a hop of delay, and those sites have terms of their own.
Read the Terms Before You Scrape
The terms are the first thing to check, before any code. Most sportsbooks' Terms of Use bar automated collection outright:
- DraftKings prohibits "using automated means (including but not limited to harvesting bots, robots, parser, spiders or screen scrapers)" to collect information from its site.1
- FanDuel prohibits using "any robot, spider, scraper, sniping software or other automated means to access the Service for any purpose" without its express written permission.2
Breaking those terms can get your traffic blocked or your account closed, and whether scraping is lawful also depends on where you are and what you collect. This guide is not legal advice. If a source's terms forbid automated access, the right move is a licensed feed, not a cleverer scraper.
Two more checks for any site you do have permission to read:
- robots.txt at the site's root lists the paths it asks crawlers to skip. It is not permission on its own, but a disallowed path is a clear no.
- An official feed. If the source offers an API or a data licence, use it. It is cheaper than a scraper to keep alive.
A Polite Fetcher in Python
For a source whose terms allow automated access, fetch politely: identify yourself, honour robots.txt, and leave seconds between requests. This helper uses only the Python standard library:
import functools, gzip, json, time, urllib.request, urllib.robotparser
from urllib.parse import urlsplit
USER_AGENT = "odds-research-bot/1.0 (+mailto:you@example.com)"
SECONDS_BETWEEN_REQUESTS = 10
last_request_at = {}
@functools.cache
def robots_for(origin):
robots = urllib.robotparser.RobotFileParser(f"{origin}/robots.txt")
robots.read()
return robots
def polite_get_json(url):
parts = urlsplit(url)
origin = f"{parts.scheme}://{parts.netloc}"
if not robots_for(origin).can_fetch(USER_AGENT, url):
raise PermissionError(f"robots.txt disallows {url}")
wait = last_request_at.get(origin, 0) + SECONDS_BETWEEN_REQUESTS - time.time()
if wait > 0:
time.sleep(wait)
headers = {"User-Agent": USER_AGENT, "Accept": "application/json", "Accept-Encoding": "gzip"}
with urllib.request.urlopen(urllib.request.Request(url, headers=headers), timeout=30) as response:
body = response.read()
if response.headers.get("Content-Encoding") == "gzip":
body = gzip.decompress(body)
last_request_at[origin] = time.time()
return json.loads(body)
Put a real contact in the User-Agent, so a site owner who objects can reach you instead of blocking you. The 10 second gap is a floor, not a target: ask for the least data, as rarely as your project allows, and cache what does not change.
The Hard Part: Matching Every Book
Fetching gives you each book's JSON. Comparing prices needs every book's quote on the same line, and four things differ from book to book:
| What differs | Book A | Book B | Book C | Book D |
|---|---|---|---|---|
| Team | BOS Celtics | Boston Celtics | Celtics | Boston |
| Market | Moneyline | Match Winner | Money Line | ML |
| Price | "+124" (text) | 2.30 (decimal) | 5/4 (fractional) | 128 (American) |
| Field names | outcomes, name, price | sel, team, odds | runners, runner, frac | away, home, american |
The usual fix is a parser per book, which turns its shape into rows, and alias tables, which turn every name into one canonical name:
from fractions import Fraction
TEAMS = {
"boston celtics": "boston celtics",
"bos celtics": "boston celtics",
"celtics": "boston celtics",
"new york knicks": "new york knicks",
"ny knicks": "new york knicks",
"knicks": "new york knicks",
}
MARKETS = {
"moneyline": "moneyline",
"money line": "moneyline",
"match winner": "moneyline",
}
def canonical(name, aliases):
key = " ".join(str(name).lower().split())
if key not in aliases:
raise KeyError(f"unmapped name {name!r}")
return aliases[key]
def american_to_decimal(american):
american = float(american)
return american / 100 + 1 if american > 0 else 100 / -american + 1
def fractional_to_decimal(fractional):
return float(Fraction(fractional)) + 1
PARSERS = {
"book_a": lambda p: [(p["market"], o["name"], american_to_decimal(o["price"])) for o in p["outcomes"]],
"book_b": lambda p: [(p["mkt"], s["team"], float(s["odds"])) for s in p["sel"]],
"book_c": lambda p: [(p["bet_type"], r["runner"], fractional_to_decimal(r["frac"])) for r in p["runners"]],
}
def normalize(book, payload):
return [
{"book": book, "market": canonical(market, MARKETS), "team": canonical(team, TEAMS), "decimal_odds": round(odds, 4)}
for market, team, odds in PARSERS[book](payload)
]
def best_prices(rows):
best = {}
for row in rows:
key = (row["market"], row["team"])
if key not in best or row["decimal_odds"] > best[key]["decimal_odds"]:
best[key] = row
return best
Fed the three payloads from the widget, best_prices returns Book B's 2.30 on the Celtics and 1.69 on the Knicks, the same +130 and −145. Two choices in it matter more than they look:
- Fail loudly.
p["runners"]raisesKeyErrorwhen Book C renames the field, andcanonicalraises on a name it has never seen. A parser that quietly returns nothing looks like a book with no odds, and you stop seeing that book's prices without knowing it. - Never guess a name. Book D's "New York" could be any New York team, so it has no alias here until a human adds one. A wrong match is worse than a missing one: it pairs prices from different games and shows you an arb that does not exist.
The moneyline is the easy case. Spreads and totals add a line, and books store it differently: one keys a spread from the home side, another from the favorite, so Celtics +3.5 and Knicks −3.5 have to land on the same line. Player props add player names, which books spell, abbreviate and suffix their own ways. Every new market type is a new alias table.
What a Scraper Costs to Keep
The first version of a scraper is the cheap part. Running it is not:
- One parser per book. A price only means something next to other books, so you maintain a parser, an alias table and a fix rota for each one.
- Silent breakage. Books redesign without notice, usually right before the busiest part of a season.
- Polling delay. A scraper sees a price when it next asks, so its average wait is half the interval, and a short-lived price can come and go between two polls. The real-time odds API guide works through that cost.
- Removals. A suspended price simply disappears from the next response, and your scraper has to notice the gap.
- No history. A scraper only knows what it has recorded. Closing prices from before you started are gone.
The Same Job with an Odds API
An odds API moves the matching to the provider. On the SmartStake Odds API, every book's quote carries the same event id, market key and team and player ids, and its quote_id encodes the line:
m ~ event ~ market_key ~ team ~ player ~ line ~ side ~ book
Drop the last two segments and you have a line id that every book's quote on both sides of the same line shares. That one string replaces the alias tables above. The API reference has the details.
Find an event, then pull its quotes from five books in decimal format:
export SMARTSTAKE_API_KEY=your-key
curl --compressed -H "Authorization: Bearer $SMARTSTAKE_API_KEY" \
"https://api.server.smartstake.ca/v1/events?league=nba"
curl --compressed -H "Authorization: Bearer $SMARTSTAKE_API_KEY" \
"https://api.server.smartstake.ca/v1/odds?event_id=EVENT_ID&book=draftkings&book=fanduel&book=betmgm&book=caesars&book=pinnacle&format=decimal"
Here is the whole matching section above, rewritten against the API. It takes the first NBA event on the board and prints the best price on every line and side:
import gzip, json, os, urllib.parse, urllib.request
API = "https://api.server.smartstake.ca"
BOOKS = ["draftkings", "fanduel", "betmgm", "caesars", "pinnacle"]
def get(path, params):
url = f"{API}{path}?{urllib.parse.urlencode(params, doseq=True)}"
headers = {"Authorization": f"Bearer {os.environ['SMARTSTAKE_API_KEY']}", "Accept-Encoding": "gzip"}
with urllib.request.urlopen(urllib.request.Request(url, headers=headers), timeout=30) as response:
body = response.read()
if response.headers.get("Content-Encoding") == "gzip":
body = gzip.decompress(body)
return json.loads(body)["data"]
event = get("/v1/events", {"league": "nba"})[0]
quotes = get("/v1/odds", {"event_id": event["id"], "book": BOOKS, "format": "decimal"})
best = {}
for quote in quotes:
line_id = quote["quote_id"].rsplit("~", 2)[0]
key = (line_id, quote["side"])
if key not in best or quote["odds"] > best[key]["odds"]:
best[key] = quote
print(f'{event["away"]} at {event["home"]}')
for (line_id, side), quote in sorted(best.items()):
print(f'{quote["label"]:<40} {quote["odds"]:>6} {quote["book"]}')
No parser per book, no alias table, and nothing to fix when a book redesigns. To keep the prices current instead of pulling them once, open the stream and apply each change, as the arbitrage scanner tutorial does in full.
When Scraping Still Makes Sense
An odds API does not cover every job. Scraping, with permission, still fits a few:
- A source the API does not carry. Check the coverage list on the Odds API page first. If the source is missing and its terms allow automated access, scrape it politely, or ask the source for a feed.
- Data that is not odds. Your own account's bet history and balances belong to your session, not to an odds feed. SmartStake reads prices; it does not place bets or read accounts through the API.
- Old prices. SmartStake's closing odds start on August 7, 2026. For earlier history you need another source, ideally a licensed dataset rather than a scraped archive.
- Learning. Building a parser for a site you own, or one that invites it, teaches the matching problem fast.
If the job is current prices from many books, side by side, a scraper is the long way round. The DraftKings API guide and FanDuel API guide cover the two books developers most often try to scrape, and the player props API guide shows the matching problem at its hardest.
FAQ
Can you scrape sportsbook odds?
Technically yes, since a sportsbook's site loads its odds as JSON that your browser can see. Most sportsbooks' terms forbid automated collection, though, and those endpoints change without notice. The SmartStake Odds API serves odds from 85+ sportsbooks, exchanges and prediction markets in one schema, so you never scrape a book.
Is scraping sportsbook odds legal?
It depends on where you are, what you collect and the site's terms, and this guide is not legal advice. Most sportsbooks' Terms of Use forbid bots, spiders and scrapers, so scraping them breaks the agreement you accept by using the site, and the book can block your traffic or close your account.
What is the hardest part of building a sportsbook odds scraper?
Matching, not fetching. Every book names teams, markets and sides its own way and prices in its own format, so the same game arrives as four different shapes. Until every name maps to one team, one market and one line, you cannot compare prices across books.
How do I find the API a sportsbook site uses?
Open the page in your browser's developer tools, go to the Network tab, filter by Fetch/XHR and reload. The odds arrive as JSON from the book's own endpoints. Those endpoints are undocumented, change without notice, and the site's terms still apply to them.
Why does my sportsbook odds scraper return nothing?
Usually one of four things: a renamed field broke your parser, the book only serves odds inside a legal state and your server is outside it, bot protection blocked the request, or the book moved the market to a different endpoint. A parser that fails loudly and an alert when a book returns zero prices catch all four.
What should I use instead of a sportsbook odds scraper?
An odds API that has already done the matching. On the SmartStake Odds API, every book's quote on the same line shares one line id, prices come in American or decimal as you ask, and changes stream to you in about a quarter of a second on average.
Get an API Key
The SmartStake Odds API replaces a scraper per book with one key. Hobby at $149 a month, for SmartStake Premium members, covers 5 sportsbooks and 5 leagues you pick, pregame only.
Pregame at $399 and Pregame + Live at $699 cover every sportsbook in 5 leagues you pick, and Full Stream at $999 covers every league. Live odds come with Pregame + Live and Full Stream.
Choose a plan. First-time subscribers to Pregame, Pregame + Live and Full Stream start with a 7-day free trial, and your key appears under API keys in SmartStake as soon as you subscribe.
Footnotes
-
DraftKings Terms of Use, prohibited conduct, as published on September 13, 2026. ↩
-
FanDuel Terms of Use, section 6, Conduct, last updated July 16, 2026, read November 8, 2026. ↩
Get the next guide in your inbox
Practical betting guides, new tools, and product updates from the SmartStake team. Unsubscribe in one click, any time.
By providing your email, you are consenting to receive communications from SmartStake. Visit our Privacy Policy for more info


