Free, open-source Python scraper for NBA betting statistics.
Pulls player game logs, team pace/ratings, shooting splits, and back-to-back detection from Basketball Reference — no API key required.
- Player game logs: PTS, REB, AST, STL, BLK, TOV, FG%, TS%, +/-, game score
- True Shooting Percentage (TS%) computed per game
- Rolling averages over configurable windows (L3, L5, L8, L15)
- Team pace, offensive rating (ORtg), defensive rating (DRtg), net rating
- Shooting splits (home/away, vs division, monthly, etc.)
- Back-to-back detection and fatigue flagging
- Filter game logs by opponent (player vs team history)
- Simplified usage rate and PER estimation
- Async with rate limiting and in-memory caching
- No API key required
pip install -r requirements.txtimport asyncio
from basketball_reference import BasketballReferenceScraper
async def main():
async with BasketballReferenceScraper() as scraper:
# Player game log
games = await scraper.get_player_gamelog("jamesle01", 2025)
print(f"LeBron: {len(games)} games")
# Rolling averages
rolling = BasketballReferenceScraper.rolling_averages(games)
for w, stats in rolling.items():
print(f"L{w}: PTS={stats['points']:.1f} AST={stats['assists']:.1f}")
# Back-to-back detection
b2b = BasketballReferenceScraper.detect_b2b(games)
print(f"B2B pairs: {len(b2b)}")
# Is today a B2B?
is_b2b = BasketballReferenceScraper.is_b2b_today(games)
print(f"Tonight is B2B second game: {is_b2b}")
# Team ratings
ratings = await scraper.get_league_ratings(2025)
for t in sorted(ratings, key=lambda x: x.net_rtg, reverse=True)[:5]:
print(f"{t.team}: ORtg={t.ortg:.1f} DRtg={t.drtg:.1f} Net={t.net_rtg:+.1f}")
asyncio.run(main())Run the included example:
python example.py| Stat | Description |
|---|---|
points |
Points scored |
rebounds |
Total rebounds |
assists |
Assists |
steals |
Steals |
blocks |
Blocks |
turnovers |
Turnovers |
minutes |
Minutes played |
fg_pct |
Field goal % (computed) |
ts_pct |
True shooting % (computed) |
plus_minus |
+/- |
game_score |
Hollinger game score |
| Stat | Description |
|---|---|
pace |
Possessions per 48 minutes |
ortg |
Offensive rating (pts per 100 poss) |
drtg |
Defensive rating (pts allowed per 100 poss) |
net_rtg |
Net rating (ortg - drtg) |
Basketball Reference player IDs are constructed as: first 5 chars of last name + first 2 chars of first name + 01.
Examples:
- LeBron James:
jamesle01 - Stephen Curry:
curryst01 - Kevin Durant:
duranke01 - Nikola Jokic:
jokicni01
- Basketball Reference — game logs, splits, team ratings
MIT — use it however you want.