Open ghadfield32 opened 7 months ago
Did you ever find a solution? Having the same issue myself, randomly stopped working
Having this same issue as well
+1 on this issue, anyone find a solution?
Same issue here
File "d:\batch\tasks\workitems\adfv2-bapredictordev01pool\job-1\94838f92-d599-4fed-9e90-c1097d4d2e5a\wd\main.py", line 75, in Main if get_query(leaguegamefinder.LeagueGameFinder().get_data_frames()[0]) is None: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\nba_api\stats\endpoints\leaguegamefinder.py", line 249, in __init__ self.get_request() File "C:\Python312\Lib\site-packages\nba_api\stats\endpoints\leaguegamefinder.py", line 252, in get_request self.nba_response = NBAStatsHTTP().send_api_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\nba_api\library\http.py", line 146, in send_api_request response = requests.get( ^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python312\Lib\site-packages\requests\adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
NBA API Version
latest
Issue
I'm having the same kind of issue as described in this post for leaguegamefinder and playergamelog. Can you tell me where I'm going wrong in my api call? It's been working for NBA season so far as I've been running some models on this data until now. Just today it started giving me the timeout error.
Code
from nba_api.stats.endpoints import leaguegamefinder import pandas as pd import time import requests
Custom headers to mimic a browser request
custom_headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3', 'Referer': 'https://stats.nba.com', 'Connection': 'keep-alive', }
def get_games_by_season(season_year_start, retries=3, delay=30): season_id = f"{season_year_start}-{str(season_year_start+1)[-2:]}"
all_seasons_data = pd.DataFrame()
for year in range(2023, 2024): season_data = get_games_by_season(year) if not season_data.empty: all_seasons_data = pd.concat([all_seasons_data, season_data], ignore_index=True) else: print(f"No data for season starting in {year}")