0

I am able to use LeagueGameFinder to get get game ids that can be passed to Boxscore to get live box score info for seasons 2019-2023. However, I get invalid responses for data prior to 2019. Anyone know why?

for example I use the following code to get the game ids

for n in range(0, number_of_seasons):
    season_name = f"20{latest_season-(n+1)}-{latest_season-n}"
    print(season_name)
    boxdata = []
    gamefinder = leaguegamefinder.LeagueGameFinder(season_nullable=season_name, league_id_nullable='00', season_type_nullable='Regular Season')
    #gamefinder = leaguegamefinder.LeagueGameFinder(season_nullable=season_name, league_id_nullable=LeagueIDNullable().nba, season_type_nullable=SeasonType().regular)
    games = gamefinder.get_data_frames()[0]
    # games.head()
    # get a list of the distinct game_ids
    game_ids = games['GAME_ID'].unique().tolist()
    # print(game_ids)
    for game_id in game_ids:
        game_data = get_data(game_id)

I then call this function which works fine for seasons 2019-2023 but fails for anything before that such as 2018-2019 season 11:27

def get_data(game_id):
    # print(game_id)
    try:
        box = boxscore.BoxScore(game_id, headers=headers)
    except:
        print("Empty Response" + game_id)
    else:
        print("Valid" + game_id)

Basically get all Empty Response when running for the 2018-2019 season but it works fine for say 2019-2020 or 2020-2021, etc.

see description above ... tried using LeagueGameFinder for seasons prior to 2019-2020 and then pass the game ids into boxscore and get invalid response for those game ids but everything is fine for seasons 2019-2023. THanks

Progman
  • 16,827
  • 6
  • 33
  • 48
  • I heard "live" boxscore endpoint didn't exist prior to 2019. When I tried to use boxscoresummaryV2 and bosscoretraditionalV2 to get the pre-2019-20 same type of data as the live boxscore .... I kept getting timeout errors. I tried time.sleep(3) between API call and also tried proxy parameter in the API call with a rotating ip addresses, but neither worked. It would just time out error. Any suggestions on how to get around the timeout errors? And why do the live endpoints not have timeout issues but the regular non-live boxscore endpoints timeout? – Ed Jeung May 09 '23 at 01:34

0 Answers0