bttmly / nba

Node.js client for nba.com API endpoints
MIT License
710 stars 180 forks source link

HTTP error #21

Closed jonyen closed 8 years ago

jonyen commented 8 years ago

I've been starting to see these errors when making a Scoreboard API call:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/scoreboard/?LeagueID=00&GameDate=02%2F01%2F2016&DayOffset=0

I can add an exception for this, but I don't know why these calls stopped working. When I actually go to the URL, it works just fine. Kind of annoying.

ppop commented 8 years ago

Not sure if you're not aware of this by now - NBA changed their API policy so you would need to provide HTTP headers with the request in order for this to work.

You will always be able to hit the endpoint from your browser on the other hand.

jonyen commented 8 years ago

Could you show me an example of how to provide the HTTP header in the request?

danielwelch commented 8 years ago

This may or may not be related, so my apologies if this is off-topic, but it looks like the stats.nba.com/stats/scoreboard endpoint was recently changed. There's some discussion of it on this reddit thread, and it appears the problem is specific to the scoreboard endpoint, or at least doesn't affect every endpoint.

When making calls to the Scoreboard endpoint, I started receiving the following 403 Forbidden error: Referral Denied: You don't have permission to access "http://stats.nba.com/stats/scoreboard/?" on this server. Reference #24.1647f8a2.1456323795.220ea02f. Same thing when trying in the browser.

It looks like you can get around this by setting the Referer header to http://stats.nba.com/scores/.

Edit: After forking and running the tests, it looks like this same error occurs for scoreboard and playerSplits methods

bttmly commented 8 years ago

Hi folks, sorry for the delay. This should be resolved in v2.0. However, it seems NBA has removed two endpoints (playerDashPtShotLog and playerDashPtReboundLogs), so those are removed and therefore it's a semver major version bump.

I used the headers from https://github.com/seemethere/nba_py/blob/79b764ec86a4740b0460ab8c75483f41247e940f/nba_py/__init__.py#L14