Build a Player Props Analyzer with Python and an Odds API
May 11, 2026
If you have spent any time betting player props, you have probably noticed that sportsbooks do not always agree on where to set a line. One book posts LeBron James at 24.5 points, everyone else is at 25.5, and suddenly you have a full point of extra cushion if you know where to look.
The problem is finding those discrepancies manually, across dozens of props and multiple books, before game time. That is exactly what this script automates. By the end of this tutorial you will have a working Python tool that pulls every player prop for any NBA game, compares lines across bookmakers, calculates a consensus, and tells you exactly where the value is sitting.
What You'll Build
You are building a Python command line script that does the heavy lifting for your prop research. Here is what it handles:
• Fetches all player props for any upcoming NBA game in real time
• Compares lines side by side across every available bookmaker
• Calculates the consensus line using mean, median, min, and max
• Flags any sportsbook whose line sits more than a point away from consensus
• Tells you which side to consider and at which book
Perfect for: Sports bettors doing pre-game research, developers building prop tools, or anyone learning to work with live odds data via API.
What You'll Need
Nothing complicated here. Before you start, make sure you have:
• Python 3.8 or newer installed on your machine
• A SportsGameOdds API key, which you can grab for free at sportsgameodds.com/pricing
• The requests library, which we will install together in the next step
• A basic comfort level with Python. You do not need to be an expert
Quick timing note: NBA player props are usually posted 12 to 24 hours before tip-off. If you run the script earlier than that and see no results, that is completely normal. NFL props tend to go up 48 or more hours before kickoff.
Step 1: Get Your Project Set Up
Start by creating a fresh directory, activating a virtual environment, and installing the one package you need:
Once that is done, set your API key as an environment variable. It is good practice to keep keys out of your code entirely, especially if you plan to share or publish the script:
Shell
export SPORTSGAMEODDS_KEY=your_api_key_here
Step 2: Create the Analyzer Script
Create a new file called analyzer.py and paste in the code below. It looks like a lot, but we will walk through exactly what each part does right after. Feel free to read through it first to get a feel for the structure.
Step 3: Run It
List upcoming NBA games
Run the script without any extra arguments to see a list of upcoming games you can analyze:
| Shell | export SPORTSGAMEODDS_KEY=your_api_key_here | python analyzer.py |
|---|
Drill into a specific game
Once you have an event ID from the list, set it as an environment variable and run again:
| Shell | export SPORTSGAMEODDS_KEY=your_api_key_here | export EVENT_ID=abc123 | python analyzer.py |
|---|
How It Works
1. Telling player props apart from team bets
The SportsGameOdds API uses a field called statEntityID to indicate what a bet is actually about. Team level odds like point spreads and game totals use values like all, home, or away. Player props use the player's unique identifier instead, for example LEBRON_JAMES_1_NBA.
The script checks this field on every odd and skips anything that looks like a team level bet, so you only ever see genuine player props in the output.
2. Pulling the line from each bookmaker
Every odds object contains a byBookmaker section. The script loops through it and pulls two things for each available sportsbook: the overUnder line (for example 25.5) and the price on each side (for example -110). If a book does not have the prop available it gets skipped.
3. Building the consensus
With all the lines collected, the script uses Python's built in statistics module to calculate the mean, median, minimum, and maximum across every book. The mean becomes the consensus benchmark that everything else is measured against.
4. Spotting the outliers
Any book whose line sits 1.0 or more points away from the consensus mean gets flagged as an outlier. A full point of difference is meaningful in most prop markets. It is the kind of gap that, over a season of bets, adds up to a real edge.
5. Figuring out which side has value
The logic here is straightforward. If a book's line is lower than consensus, hitting the over there is easier than it would be at other books. If the line is higher, the under becomes the more attractive side. The script surfaces both opportunities clearly so you can decide quickly.
A Real Example: LeBron James Points
Here is what the analysis looks like in practice. Eight books are offering the prop and the consensus lands at 25.5 points. Two books are flagged as outliers, highlighted below:
| Bookmaker | Line | Over | Under | vs Consensus |
|---|---|---|---|---|
| DraftKings | 25.5 | -110 | -110 | — |
| FanDuel | 25.5 | -108 | -112 | — |
| Caesars | 25.5 | -110 | -110 | — |
| BetMGM ★ | 24.5 | -105 | -115 | -1.0 pt (OVER value) |
| Barstool ★ | 26.5 | -110 | -110 | +1.0 pt (UNDER value) |
BetMGM is sitting a full point below everyone else at 24.5. If LeBron scores exactly 25 points tonight, you win the over at BetMGM but lose at every other book. That is the edge the script finds automatically, without you having to open eight different apps and compare manually.
Ways to Take It Further
Track how lines move over time
Each time you run the script, save a snapshot of the odds to a file. Compare snapshots over time and you can see when lines shift sharply before tip-off, which is often a sign of sharp money coming in or a late injury update.
Filter by prop type
On a busy game day you might only care about points props or rebounds. Adding a simple filter argument to the script lets you cut through the noise and focus on what matters to you.
Export everything to a spreadsheet
Python's built in csv module makes it easy to write all your props and bookmaker data to a file you can open in Excel or Google Sheets. Great for sharing with a group or doing deeper analysis over a longer period.
Calculate expected value
The starter calculate_ev() function in the script gives you a foundation to build on. Convert American odds to decimal, factor in the line distance from consensus, and you can start making decisions based on expected value rather than gut feel.
Things That Might Go Wrong
The script says no player props were found
This is almost always a timing issue rather than a code problem. NBA props typically go live 12 to 24 hours before tip-off, and NFL props appear 48 or more hours out. Run the script again when you are closer to game time and you should see them appear.
Some players are missing from the output
Bookmakers only post props for starters and key bench players, usually somewhere between 10 and 15 players per NBA game. Spot players and anyone listed as a DNP will not have lines posted.
Player names are showing up as raw IDs
Make sure you are calling format_player_name() wherever you print player names in the output. If you use the raw statEntityID value directly you will see identifiers like LEBRON_JAMES_1_NBA instead of a readable name.
Getting a 401 error from the API
This almost always means the environment variable is not set in your current shell session. Double check that you have run the export command in the same terminal window you are using to run the script.
What to Build Next
Once this analyzer is running smoothly, it pairs really well with a few other tools in the SportsGameOdds documentation:
- Live Odds Tracker: monitor prop line movement in real time as game time gets closer
- Arbitrage Calculator: check whether the spread between books creates a risk free opportunity
- Parlay Builder: combine your best value props and calculate the combined odds
Get your free API key at sportsgameodds.com/pricing and you can have this running in under 10 minutes.
The full API documentation lives at sportsgameodds.com/docs if you want to explore what else is possible.