seemethere / nba_py

Python client for NBA statistics located at stats.nba.com
BSD 3-Clause "New" or "Revised" License
1.05k stars 255 forks source link

Deploying Flask App with nba_py #91

Closed worldofnick closed 6 years ago

worldofnick commented 7 years ago

Has anyone sucecssfully deplpyed a flask app that uses nba_py? I have used Heroku and pythonanywhere and both times it doesn't work when I try to request game information. It just times out.

On Heroku when I open the command line and type scoreboard = nba_py.Scoreboard(month=2, day=21, year=2015) the command never executes just hangs there.

bttmly commented 7 years ago

NBA.com seems to block known IP address blocks from cloud hosting providers, including AWS and Heroku

https://github.com/seemethere/nba_py/issues/88

worldofnick commented 7 years ago

@bttmly Do you know of anyway to get around this?

bttmly commented 7 years ago

Many endpoints allow a JSONP API, which can be accessed directly by a web client. When you do that, the requesting IP address is that of the client's own computer, so you circumvent this restriction. This would mean your app would have to run in the browser though; not sure what your use case is.

Otherwise you can host your application on a provider that NBA doesn't block. I just ran a request to NBA through a Node.js client from a server hosted by Linode and it worked (disclaimer: I couldn't get a similar curl command to work, no idea why).

Shameless plug: I wrote a Node.js/browser NBA client in JavaScript which supports JSONP: https://github.com/bttmly/nba

EDIT: Not sure if the npm installation of that package currently supports browsers. Ping me if you need help on that