NBA API PHP LibraryView on GitHub
The NBA provides an enormous amount of undocumented filterable public data via URL endpoints on their websites. This includes statistical data as well as general/historical information about the league, its teams, players, and more. Most of this information is returned as JSON data, but there are also endpoints that retrieve data in XML and PDF formats.
The goal of this library is to provide an easy-to-use client to access and process all currently-known NBA endpoints. At this time, that number is 242. No other library has more than 100 endpoints.
Endpoints / Requests
Each endpoint in the library is tied to a Request class. For more information about how these requests work, see the Requests section of the documentation. At the highest level, requests are available from the following domains:
The sidebar has a request reference that provides easy access to information about every request. This is not just a programming reference; even non-programmers can run full examples right from this site to retrieve data, and even filter all available options on every report.
Go ahead, try out an example!
In order to use this library you need to be using PHP 7.0 or later and composer for package management.
This library is completely open source and released under the MIT license. You may fork the code for your own use, but if you have potential improvements or enhancements to the code, I welcome discussion and pull requests to place them into the main library.
Support / Troubleshooting
If you are having trouble retrieving requests that access
stats.nba.com/stats/, it appears that
the NBA has blocked off access to these endpoints on some level; this blocking seems to occur on many cloud
hosting providers such as Amazon AWS, Digital Ocean, and Heroku.
In my testing, these endpoints have always worked when developing locally.
The NBA API PHP Library (and this website) was developed by Jason Roman. Feel free to contact me with any questions, comments, or suggestions to improve this library at firstname.lastname@example.org or on Twitter at @_jasonroman