Skip to content

mtarcure/basketball-betting-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basketball Betting Scraper

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.

Features

  • 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

Installation

pip install -r requirements.txt

Quick Start

import 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

Stats Available

Player Game Log (GameLogEntry)

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

Team Ratings (TeamRatings)

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)

Player ID Format

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

Data Sources

License

MIT — use it however you want.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages