nba_api
nba_api copied to clipboard
Getting NBA Schedule?
Hey guys, fantastic resource. I am currently trying to return the NBA schedule, ideally from a start_date
to and end_date
. The LeagueGameLog
endpoint returns the information on past games and it can't be used to return scheduled (future) games. The PlayerNextNGames
class seems to return what I want but it is at a player level. Would be amazing if this could be done league wide in one call.
Does anyone know how this might be done? Thanks!
Edit:
Found that you can call the following endpoint for this seasons schedule: http://data.nba.com/data/10s/v2015/json/mobile_teams/nba/2020/league/00_full_schedule.json
import requests
r = requests.get("http://data.nba.com/data/10s/v2015/json/mobile_teams/nba/2020/league/00_full_schedule.json")
r.json()
Not ideal because I rather use the library's classes and functions but it is my current work around.
@JaumeClave - Thanks for pointing out that json file. stats.nba.com
as you noticed is for historical data. I have a PR pending that will add live data through https://cdn.nba.com/static/json/liveData
. For the schedule, I'll have to see how the NBA manages this file and if they have it on https://cdn.nba.com
. I would suspect it's there. Curious if they maintain history as well. I've found the cdn site to have historical data that was once live.
Could you give me the steps you took to find this?
The NBA schedule can be found on the CDN page here: https://cdn.nba.com/static/json/staticData/scheduleLeagueV2.json @rsforbes.
Similar to @JaumeClave's link, this site also appears to have the schedule: https://data.nba.com/data/10s/v2015/json/mobile_teams/nba/2020/league/00_full_schedule_week_tbds.json. I'm not sure about the difference between the two.
I don't have a strong view as to which source of the schedule is better/more reliable to use.
@rsforbes - The ability to get live data would be fantastic, thanks. I found the resource shared on a question asked in 2016 on the r/nba subreddit (here). The first response shares the same link I shared but for the 2015 season. I clicked through it and changed the 2015 URL element to 2020 in order to return this seasons schedule.
I haven't validate the schedule. I'll be doing some analysis with it today/this week and I'll report back with its accuracy.
I can actually add this functionality. I've been using the http://data.nba.com/data/10s/v2015/json/mobile_teams/nba/2020/league/00_full_schedule.json to return a specific team's weekly schedule and using this to help me out in yahoo fantasy (not much help, still lost).
Another endpoint you could use is https://data.nba.net/prod/v1/2020/schedule.json.
Sorry for digging up this old issue (idk if this will notify anyone) but i think I may have found a nice endpoint to get the schedule for a given day.
Endpoint Template (guess)
https://stats.nba.com/stats/internationalbroadcasterschedule?LeagueID=00&Season={season}&RegionID=1&Date={date}&EST=Y
Where
-
season
is the year the season started (ex. 2021-22 would be 2021) -
date
is formatted likem/d/yyyy
Valid url
https://stats.nba.com/stats/internationalbroadcasterschedule?LeagueID=00&Season=2021&RegionID=1&Date=5/21/2022&EST=Y
The following URL works for a specific season: https://stats.nba.com/stats/scheduleleaguev2?Season=2020-21&LeagueID=00