Open ilakisp opened 4 years ago
Same issue. Non-responsive.
I think nba.com has been in a long process of deprecating the endpoints under the stats.nba.com/stats umbrella – they seem to be moving to data.nba.com/data endpoints (here is a short list of ones I've found so far – I'm hoping to find some time to scan their site and add more soon). Seems like today they finally shut down the old endpoints.
Hey guys, found a temporary workaround. I realised the endpoints would work if clicked from a browser, so trialed and errored with the headers until I came up with a fix. Set the 'Referer' field in the header to 'https://github.com'. Weird I know. Not sure if its any website - didn't test any others.
I can confirm that after the endpoints not working for the last couple of days, adding a 'Referer' to the header allows successful calls. On the website they use 'https://stats.nba.com[/whatever_slug]', which you can see through the F12 header data on Chrome. I've added https://stats.nba.com as the 'Referer'. (Thanks @calebcheng00 !)
Anybody have a curl
example of a working request?
EDIT: figured it out, thanks for the pointer
I can get a curl request to work but if I put that same curl request into postman it doesn't work. How can their endpoints differentiate the two?
Since this repository seems rather dead and unmaintained, I opened up a fork that I'm going to try to update and would love some help!
I'd be happy to help. I think the first thing we need to do is figure out how nba.stats can differentiate between http requests originating from their website and requests sent programmatically or from postman. I've copied their exact request into postman and I can never get a response from the server. do you have any ideas? the only thing that's worked for me is curling their endpoints
On Tue, Nov 26, 2019, 2:31 PM jtpavlock notifications@github.com wrote:
Since this repository seems rather dead and unmaintained, I opened up a fork https://github.com/jtpavlock/nba_stats that I'm going to try to update and would love some help!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/seemethere/nba_py/issues/137?email_source=notifications&email_token=AEXNICXBWTH6U6RP7LY76ETQVWIRHA5CNFSM4JKNZ4KKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFHQAQI#issuecomment-558825537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXNICVRZQM66L3XM5QJLBLQVWIRHANCNFSM4JKNZ4KA .
what's the curl command you're using? I'll try some testing too
curl 'https://stats.nba.com/stats/leagueseasonmatchups?DateFrom=&DateTo=&DefPlayerID=201935&LeagueID=00&Outcome=&PORound=0&PerMode=Totals&Season=2019-20&SeasonType=Regular+Season' -H 'Pragma: no-cache' -H 'X-NewRelic-ID: VQECWF5UChAHUlNTBwgBVw==' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'x-nba-stats-token: true' -H 'Cache-Control: no-cache' -H 'Referer: https://stats.nba.com/player/201935/matchups/' -H 'Cookie: AMCV_7FF852E2556756057F000101%40AdobeOrg=2121618341%7CMCIDTS%7C18227; ak_bmsc=D3C47F47C7854F5EF8C52104FFB7D432A5FE92F5832A0000129EDD5DAE6FDF18~plFYKOsPevJH4vwuVBmVI4p2Ay9xCoFvV9VgTIN/GTy5WBvS1f0v07vDxZZ+5A9imiEnCxFksW8NWP5UkUXj+ukvfO1ktwVeNR80zLtkYQ66RVwE/hOA6kGJEpA+cGFY45ECDLdLOpCNvRBoZv8CAyM06ww2P33HjsYDAiIjn1jc6Iu79JHZV//h9/5cmSDySMyTIG0PsASKZNzBuANawc+M7+swuCZgsnTZS6uWiDAnA=; bm_sv=F2CD98378B4D66B61BF397158D36F86F~zF3TfhhblfR/SYvB8Oidv2jq5oAEv4Zx1IYmZRaj8ijNBnYba/3y0J2yqAAuZy5JXtQ8NDu8EyP0GIxj9ZWXB522cZi6Nyoe4qT58QazbPT1fPzETh+5rUr7OCUznhoN1GXg1UK3UTdEQl0DjA7lxg==' -H 'Connection: keep-alive' -H 'x-nba-stats-origin: stats' --compressed
I just got this from the chrome dev tools network tab. You can right click an XHR and select copy as curl. I've been trying to get matchup data
I checked out this stackoverflow post and disabling sending the postman token header worked for me
yeah you can import curl commands into postman and it will populate the headers for you. I've tried that in addition to copying headers over by hand and nothing works. postman has a token header they send with requests, I disabled that, still no luck. I've tried axios and fetch functions inside a webpage, no response. the only way I've been able to programmatically access their data is by creating a node script that spawns a child process which executes the curl command. that's dirty as hell though.
On Tue, Nov 26, 2019, 2:58 PM jtpavlock notifications@github.com wrote:
Are you copying the headers into postman with the request?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/seemethere/nba_py/issues/137?email_source=notifications&email_token=AEXNICUCTMACQV4UKK5K2YLQVWLXZA5CNFSM4JKNZ4KKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFHSJZI#issuecomment-558834917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXNICXJMNDAQ25P377CHMDQVWLXZANCNFSM4JKNZ4KA .
Heads up I have my fork, nbapy up and running on pip. I tried to clean up the code a bit and add some tests. I'm hoping others may hop on board and help with any new endpoints/docs but mostly with keeping it up to date against any changes with nba.com.
@jtpavlock I've been hoping for a while to consolidate efforts across languages. I think we can create a system where we describe the available endpoints (and perhaps even the response shapes?) in JSON, and use dynamic language features to generate clients programmatically. This will help all clients stay up to date and let everyone benefit from updates. I have a project here https://github.com/bttmly/nba-client-template which implements this for the stats.nba.com endpoints. However, nba.com appears to be deprecating those endpoints in favor of brand new endpoints at data.nba.com. If we all have to move to new endpoints, it'd be great to share work!
@skyrob CORS generally prevents you from requesting it through the browser, but you can definitely request it through Node.js without shelling out to cURL
. You can demonstrate this by running the tests on my node NBA client https://github.com/bttmly/nba. Your issue is likely due to Referer and/or Origin headers – try setting both to stats.nba.com
. Or use the following example
const fetch = require("node-fetch");
(async () => {
const res = await fetch("http://stats.nba.com/stats/playerprofilev2?LeagueID=00&PerMode=PerGame&PlayerID=201939&Season=2017-18", {
headers: { Referer: "stats.nba.com", Origin: "stats.nba.com" },
});
console.log(await res.json())
})()
Heads up I have my fork, nbapy up and running on pip. I tried to clean up the code a bit and add some tests. I'm hoping others may hop on board and help with any new endpoints/docs but mostly with keeping it up to date against any changes with nba.com.
i am using @jtpavlock's fork- -but haven't difficulty using the same code examples... i am trying to simply loop thru all boxscores
Is it me or it stopped working again? I cant get a response since yesterday...
Just for reference I am not getting a response in the browser or using the module.
@luzer your issues should be fixed, but let me know if otherwise.
@bttmly Sorry for the late response. It is a good idea, but a lot of my work was based off of this repo, and it would take a considerable amount of effort to change that while maintaining a decent user interface to the API and allowing for auto documentation. I created some documentation that still needs a lot of work, but perhaps can eventually evolve into a sensible reference for all clients.
Hey guys, found a temporary workaround. I realised the endpoints would work if clicked from a browser, so trialed and errored with the headers until I came up with a fix. Set the 'Referer' field in the header to 'https://github.com'. Weird I know. Not sure if its any website - didn't test any others.
how can I do this in flask can anyone help
Hi all,
I'm not sure if anyone's having issues, but though I've been able to use nba_py daily, since today it seems to be non-responsive. Did anyone by any chance look into this and know what the issue is or a potential sollution?
Thanks :)