Objects

Day

Instantiating a Day object will load all resources for the Day object that were set in the settings when the client was instantiated

The following code will instantiate the client and get game data for games played on 02/03/2020

from pbpstats.client import Client

settings = {
    "dir": "/response_data",
    "Games": {"source": "web", "data_provider": "stats_nba"}
}
client = Client(settings)
day = client.Day("02/03/2020", "nba")
for game in day.games.items:
    print(game.data)
class pbpstats.objects.day.Day(date, league)[source]

Bases: object

Class for loading resource data from data loaders with a parent_object of Day

Parameters:
  • date (str) – Formatted as MM/DD/YYYY
  • league (str) – Options are ‘nba’, ‘wnba’ or ‘gleague’

Game

Instantiating a Game object will load all resources for the Game object that were set in the settings when the client was instantiated

The following code will instantiate the client and get possession data for game id 0021900001 from files in /response_data subdirectories

from pbpstats.client import Client

settings = {
    "dir": "/response_data",
    "Possessions": {"source": "file", "data_provider": "stats_nba"}
}
client = Client(settings)
game = client.Game('0021900001')
for possession in game.possessions.items:
    print(possession)
class pbpstats.objects.game.Game(game_id)[source]

Bases: object

Class for loading resource data from data loaders with a parent_object of Game

Parameters:game_id (str) – NBA Stats Game Id

Season

Instantiating a Season object will load all resources for the Season object that were set in the settings when the client was instantiated

The following code will instantiate the client and get all games for the 2019-20 NBA Regular Season and store the schedule response in a /response_data subdirectory

from pbpstats.client import Client

settings = {
    "dir": "/response_data",
    "Games": {"source": "web", "data_provider": "data_nba"}
}
client = Client(settings)
season = client.Season("nba", "2019-20", "Regular Season")
for game in season.games.items:
    print(game)
class pbpstats.objects.season.Season(league, season, season_type)[source]

Bases: object

Class for loading resource data from data loaders with a parent_object of Season

Parameters:
  • league (str) – Options are ‘nba’, ‘wnba’ or ‘gleague’
  • season (str) – Can be formatted as either 2019-20 or 2019.
  • season_type (str) – Options are ‘Regular Season’ or ‘Playoffs’ or ‘Play In’