New NBA API Library / Website
Posted: Tue Oct 03, 2017 8:58 pm
Hi all. You might recall, before the 2017 draft I posted a little site I whipped up to compare draft pick trade value charts based on Kevin Pelton's article(s) on the topic. In the meantime I have been working on a couple things that many of you might be interested in.
The first is a new open-source client library in the mold of nba.js and nba_py. It's written in PHP, uses modern programming techniques/libraries, is fully unit-tested, and is very, very easy to use. You can find it on GitHub at the following link: https://github.com/jasonroman/nba-api . One of the main advantages my library currently has over the others is the amount of data it can pull. Most other libraries have around 80 endpoints of data, but I've discovered 242. There's a whole wealth of information (and not just stats) that you can grab from the NBA. I plan to update regularly, and being open-source, I hope that my library becomes the unofficial place to find every endpoint.
The second thing is a new website - http://nbasense.com . This does contain the original Draft Pick Trade Value Chart tool, but more importantly it contains *extensive* documentation for using my new open-source library. I give you all of the code right on the site that you can use to create your requests.
What I'm even more proud of is the documentation I have on all 242 requests. With every request you have:
- the URL endpoint along with any placeholders
- a link to the request class on GitHub
- code you can copy/paste to generate a response
- code you can copy/paste that contains every filterable variable and default/example values for each
- an example URL that you can open to see what the request returns
- an example URL that you can submit to my library and retrieve as a traversable array/object right in the browser
- a listing of every single parameter you can enter for the request, telling you the data type, allowed values/choices, and default value
- a dynamically generated form for filtering data
I want to touch on the last point since it's the one I'm most proud of. For any request, my website creates a form that contains every single parameter in that request, along with default/example values. You can change any of these fields and submit the form. Upon submitting, I create the dynamic URL endpoint based on your search criteria. I also create the specific PHP code for that request containing your search criteria that you can copy/paste. I also show you a traversable array/object of all the results. For example, check that out here: http://nbasense.com/nba-api/Data/Prod/T ... playground
So essentially, even if you don't want to use PHP, or my library, you can still use my website to generate any of the available 242 URLs and pass that into your own client, or just take the resulting raw JSON/XML data and pass it to R or Python, or cURL, or whatever you want. It's as flexible as you want/need it to be.
The only caveat is that right now the NBA is blocking my requests to 102 of the 104 stats.nba.com/stats endpoints from nbasense.com, which I know are some of the most useful endpoints. So if you submit my form for one of those requests you'll only see the URL/code, and not the result directly in the browser. I think they block a lot of web hosts like DigitalOcean, Heroku, and DreamHost. I have yet to find a solution for that, but I'm working on it.
Anyway, enjoy!
The first is a new open-source client library in the mold of nba.js and nba_py. It's written in PHP, uses modern programming techniques/libraries, is fully unit-tested, and is very, very easy to use. You can find it on GitHub at the following link: https://github.com/jasonroman/nba-api . One of the main advantages my library currently has over the others is the amount of data it can pull. Most other libraries have around 80 endpoints of data, but I've discovered 242. There's a whole wealth of information (and not just stats) that you can grab from the NBA. I plan to update regularly, and being open-source, I hope that my library becomes the unofficial place to find every endpoint.
The second thing is a new website - http://nbasense.com . This does contain the original Draft Pick Trade Value Chart tool, but more importantly it contains *extensive* documentation for using my new open-source library. I give you all of the code right on the site that you can use to create your requests.
What I'm even more proud of is the documentation I have on all 242 requests. With every request you have:
- the URL endpoint along with any placeholders
- a link to the request class on GitHub
- code you can copy/paste to generate a response
- code you can copy/paste that contains every filterable variable and default/example values for each
- an example URL that you can open to see what the request returns
- an example URL that you can submit to my library and retrieve as a traversable array/object right in the browser
- a listing of every single parameter you can enter for the request, telling you the data type, allowed values/choices, and default value
- a dynamically generated form for filtering data
I want to touch on the last point since it's the one I'm most proud of. For any request, my website creates a form that contains every single parameter in that request, along with default/example values. You can change any of these fields and submit the form. Upon submitting, I create the dynamic URL endpoint based on your search criteria. I also create the specific PHP code for that request containing your search criteria that you can copy/paste. I also show you a traversable array/object of all the results. For example, check that out here: http://nbasense.com/nba-api/Data/Prod/T ... playground
So essentially, even if you don't want to use PHP, or my library, you can still use my website to generate any of the available 242 URLs and pass that into your own client, or just take the resulting raw JSON/XML data and pass it to R or Python, or cURL, or whatever you want. It's as flexible as you want/need it to be.
The only caveat is that right now the NBA is blocking my requests to 102 of the 104 stats.nba.com/stats endpoints from nbasense.com, which I know are some of the most useful endpoints. So if you submit my form for one of those requests you'll only see the URL/code, and not the result directly in the browser. I think they block a lot of web hosts like DigitalOcean, Heroku, and DreamHost. I have yet to find a solution for that, but I'm working on it.
Anyway, enjoy!