1

What I tried:

from nba_api.stats.static import teams
from nba_api.stats.endpoints import leaguegamefinder
import pandas as pd

nba_teams = teams.get_teams()

def one_dict(list_dict):
    keys = list_dict[0].keys()
    out_dict = {key:[] for key in keys}
    for d in list_dict:
        for key,value in d.items():
            out_dict[key].append(value)
    return out_dict
dict_nba_team = one_dict(nba_teams)
df = pd.DataFrame(dict_nba_team)
search_id = list(df[df['nickname']=='Hawks']['id'])[0]
gamefinder = leaguegamefinder.LeagueGameFinder(team_id_nullable = search_id)
games = gamefinder.get_data_frames()[0]
games.head()

Error:

ReadTimeout: HTTPSConnectionPool(host='stats.nba.com', port=443): Read timed out. (read timeout=30)

  • Works fine on my end. Do you need to use this package. Would you be fine with going through stats.nba.com without this wrapper? – chitown88 Apr 04 '21 at 17:09

1 Answers1

0

Hello,
I have looked into this issue on cannot offer a solution, but can give you an answer on this.

LeagueGameFinder provides a variety of statiscal information about the NBA games. It is in the path:
nba_api/docs/nba_api/stats/endpoints/
of the NBA API. It is one of many statistical modules of the API.
Github

The file analysis.json offers an overview about the validation state for the NBA API. According to this the endpoint was validated last year and works.

However at the point of this project the API does not work. Github users discussing several solutions.

One solution is updating. This did not work for me. Another suggestion is working around the timeout error with looping. This seems not feasible and could create a black listing. The solution could be to adapt the API source code to the changes on the server site. This would be a substantial effort probably. Also it is not clear if the error relies on the code, but on the sys-admin. It maybe the case that the API will work again for unknown server site reasons.

In general the API's maintained by communities but also by enterprises are prone to dysfunction and must be validated regularly. As the data architecture of the data provider NBA changes the API's should be adapted. This is not always the case as the adaption relies on the community. The server site can then create issues, which are not solved by the client-API-site.

Ormetrom2354
  • 315
  • 3
  • 11