nba_api icon indicating copy to clipboard operation
nba_api copied to clipboard

Is the API still working? Are there new headers?

Open sbut1992 opened this issue 5 years ago • 11 comments

Hey I'm not able to connect to any of the endpoints, I get this error...

readtimeout: httpsconnectionpool(host='stats.nba.com', port=443): read timed out. (read timeout=30)

These are the headers I'm using...

{
    'Host': 'stats.nba.com',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'en-US,en;q=0.5',
    'Referer': 'https://stats.nba.com/',
    'Accept-Encoding': 'gzip, deflate, br',
    'Connection': 'keep-alive',
    'x-nba-stats-origin': 'stats',
    'x-nba-stats-token': 'true'
}

Can someone help me?

sbut1992 avatar Jul 20 '20 12:07 sbut1992

I had the same problem, someone mentioned to use time.sleep() before each API call as a temp solution and that's worked for me.

ivankuadey avatar Jul 20 '20 21:07 ivankuadey

Still getting timeouts when calling leagueSeasonMatchups. Only calling the API once so time.sleep() is not applicable here. Has anyone else had this problem?

Skytrobb avatar Jul 28 '20 05:07 Skytrobb

yes I have the same problem.

BekeleNatan avatar Jul 31 '20 14:07 BekeleNatan

@sbut1992 Did you find a solution ?

BekeleNatan avatar Jul 31 '20 15:07 BekeleNatan

I have the same error!!! endpoint with required arguments are timed out!!!

JSK25 avatar Aug 06 '20 17:08 JSK25

What endpoints are you calling and where from? Myself and others have seen issues in running from AWS (looks like the NBA blocks calls from there). I've run through the Jupyter Notebooks locally today and haven't had any issues. If you are making consecutive calls to the api, you'll need to put in minimum sleep of time.sleep(.600)

rsforbes avatar Aug 09 '20 15:08 rsforbes

Thanks for your response, I am using google Colab. Actually I am new in using APIs.

The code I used is: !pip install nba_api from nba_api.stats.endpoints import commonplayerinfo player_info = commonplayerinfo.CommonPlayerInfo(player_id=2544)

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

but I could call another endpoint without any attributes(only this one): !pip install nba_api from nba_api.stats.endpoints import assistleaders player_info = assistleaders.AssistLeaders() player_info.assist_leaders.get_data_frame() I got the required output for the above code.

May be my code might be wrong.Can you give the basic code for calling these endpoints. Thank you Sir.

JSK25 avatar Aug 09 '20 17:08 JSK25

Also having timeout issues myself right now

sword134 avatar Aug 09 '20 19:08 sword134

times out when using postman or from my Django server being run locally. works fine with curl though

Skytrobb avatar Aug 09 '20 19:08 Skytrobb

@JSK25 - I had to connect Google Colab to my local Jupyter runtime in order to be successful. Myself and several others have run into issues where the NBA appears to have blocked cloud providers.

I was able to get up and running by connecting Google Colab to my local environment and pass my calls through there. It's a bit complicated, but it works. Given that you are running through your local, I'm not certain how much that buys you though as you might as well just run Jupyter locally rather than through Google Colab.

Here's the docs for that. https://research.google.com/colaboratory/local-runtimes.html

As for the others, I'm not having any issues in connecting and working with data. Again, everything is of my local box and not running on a cloud provider.

rsforbes avatar Aug 09 '20 19:08 rsforbes

I have tried my code on Jupiter also. But didn't worked out. Actually what am I missing out?

JSK25 avatar Aug 09 '20 20:08 JSK25