Skip to main content

bbref_team_game_logs

This python package scrapes Basketball Reference to return a team's regular season game log for an entire NBA season.

Installing this package

pip install bbref-team-game-logs

API

get_team_game_logs(team,season_end_year)

Parameters:

  • team : abbreviation for NBA team i.e ('PHO','DAL','BOS')
  • season_end_year: end year of an NBA season ('2005' for the 2004-2005 season)

Returns:

A pandas data frame with the following columns

['Game #' 'Date' 'H/A' 'Opponent' 'W/L' 'Team PTS' 'Opponent PTS'
'Team FG' 'Team FGA' 'Team FG%' 'Team 3P' 'Team 3PA' 'Team 3P%' 'Team FT'
'Team FTA' 'Team FT%' 'Team ORB' 'Team TRB' 'Team AST' 'Team STL'
'Team BLK' 'Team TOV' 'Team PF' 'Opponent FG' 'Opponent FGA'
'Opponent FG%' 'Opponent 3P' 'Opponent 3PA' 'Opponent 3P%' 'Opponent FT'
'Opponent FTA' 'Opponent FT%' 'Opponent ORB' 'Opponent TRB'
'Opponent AST' 'Opponent STL' 'Opponent BLK' 'Opponent TOV' 'Opponent PF']

get_team_game_logs_adv(team,season_end_year)

Parameters:

  • team : abbreviation for NBA team i.e ('PHO','DAL','BOS')
  • season_end_year: end year of an NBA season ('2005' for the 2004-2005 season)

Returns:

A pandas data frame with the following columns

['Game #' 'Date' 'H/A' 'Opponent' 'W/L' 'Team PTS' 'Opponent PTS' 'ORtg'
'DRtg' 'Pace' 'FTr' '3PAr' 'TS%' 'TRB%' 'AST%' 'STL%' 'BLK%'
'Offensive eFG%' 'Offensive TOV%' 'Offensive ORB%' 'Offensive FT/FGA'
'Defensive eFG%' 'Defensive TOV%' 'Defensive DRB%' 'Defensive FT/FGA']

Example

from bbref_team_game_logs import get_team_game_logs, get_team_game_logs_adv
team = 'PHO'
year = '2005'
df = get_team_game_logs(team,year)
df_adv = get_team_game_logs_adv(team,year)

The code above should retreive the data from the following pages here and here

Basketball Reference Team Abbreviations

These are BBREF's abbreviation for NBA teams. Use this link here to figure out what years they have been active

ATLANTA HAWKS : ATL
ST. LOUIS HAWKS : SLH
MILWAUKEE HAWKS : MIL
TRI-CITIES BLACKHAWKS : TCB
BOSTON CELTICS : BOS
BROOKLYN NETS : BRK
NEW JERSEY NETS : NJN
CHICAGO BULLS : CHI
CHARLOTTE HORNETS : CHO
CHARLOTTE BOBCATS : CHA
CLEVELAND CAVALIERS : CLE
DALLAS MAVERICKS : DAL
DENVER NUGGETS : DEN
DETROIT PISTONS : DET
FORT WAYNE PISTONS : FWP
GOLDEN STATE WARRIORS : GSW
SAN FRANCISCO WARRIORS : SFW
PHILADELPHIA WARRIORS : PHI
HOUSTON ROCKETS : HOU
INDIANA PACERS : IND
LOS ANGELES CLIPPERS : LAC
SAN DIEGO CLIPPERS : SDC
BUFFALO BRAVES : BUF
LOS ANGELES LAKERS : LAL
MINNEAPOLIS LAKERS : MIN
MEMPHIS GRIZZLIES : MEM
VANCOUVER GRIZZLIES : VAN
MIAMI HEAT : MIA
MILWAUKEE BUCKS : MIL
MINNESOTA TIMBERWOLVES : MIN
NEW ORLEANS PELICANS : NOP
NEW ORLEANS/OKLAHOMA CITY HORNETS : NOK
NEW ORLEANS HORNETS : NOH
NEW YORK KNICKS : NYK
OKLAHOMA CITY THUNDER : OKC
SEATTLE SUPERSONICS : SEA
ORLANDO MAGIC : ORL
PHILADELPHIA 76ERS : PHI
SYRACUSE NATIONALS : SYR
PHOENIX SUNS : PHO
PORTLAND TRAIL BLAZERS : POR
SACRAMENTO KINGS : SAC
KANSAS CITY KINGS : KCK
KANSAS CITY-OMAHA KINGS : KCK
CINCINNATI ROYALS : CIN
ROCHESTER ROYALS : ROR
SAN ANTONIO SPURS : SAS
TORONTO RAPTORS : TOR
UTAH JAZZ : UTA
NEW ORLEANS JAZZ : NOJ
WASHINGTON WIZARDS : WAS
WASHINGTON BULLETS : WAS
CAPITAL BULLETS : CAP
BALTIMORE BULLETS : BAL
CHICAGO ZEPHYRS : CHI
CHICAGO PACKERS : CHI
ANDERSON PACKERS : AND
CHICAGO STAGS : CHI
INDIANAPOLIS OLYMPIANS : IND
SHEBOYGAN RED SKINS : SRS
ST. LOUIS BOMBERS : SLB
WASHINGTON CAPITOLS : WAS
WATERLOO HAWKS : WAT

Metadata

Release files for bbref-team-game-logs 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bbref-team-game-logs 1.0.3
File Size Uploaded Provenance Actions
bbref_team_game_logs-1.0.3.tar.gz 4.0 kB Without provenance Details for bbref_team_game_logs-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bbref-team-game-logs 1.0.3
File Interpreter ABI Platform Actions
bbref_team_game_logs-1.0.3-py3-none-any.whl Python 3 none any Details for bbref_team_game_logs-1.0.3-py3-none-any.whl

Total release size: 9.1 kB

Release files / bbref_team_game_logs-1.0.3.tar.gz

Download URL bbref_team_game_logs-1.0.3.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0c89cf017e83f1bc2383ade122293a612749aef869fe3289aa4a211370bf4b32
BLAKE2b-256 checksum
How to use checksums
f84d80a648b2b9b0576284c7f826b884702af210d8659234865fc9f6ede6df6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Release files / bbref_team_game_logs-1.0.3-py3-none-any.whl

Download URL bbref_team_game_logs-1.0.3-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41798fc4bea98fee3da3e713f59d71ac19c73462706b0b74dde087e3cdd1711b
BLAKE2b-256 checksum
How to use checksums
05b85bbf6f96da791b6911ad828fdc1f422aa36f55c51665315a78637e90b9a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Security for bbref-team-game-logs 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page