top of page
  • Writer's pictureBen Ballard

The NBA API Overview: Endpoints Breakdown

The NBA API is a great source to grab NBA data for data science or data analytics projects. But there are many end-points! What's the right one? What parameters are necessary? This article aims to provide an overview of the available endpoints.


First, as a quick plug , I created an Custom-GPT called my NBA API buddy which allows one to have a conversation with a chatbot where the user asks questions about what data they want to pull, and the chat bot will facilitate that query building process with the data scientist. I wrote about this in a medium article. https://medium.com/data-science-cowboy/my-first-custom-gpt-e1067320ad70



NBA API Data In the Real World, NBA API
NBA API Data In the Real World

In this article, we will focus on detailing the endpoints. To fully understand the NBA API endpoints, it's important to understand not just how to access them but also what potential analyses could be performed with the data they provide. Let's delve into each endpoint with more details, including python code examples and potential analyses or use-cases:


1.) Player Career Stats (playercareerstats)


The playercareerstats endpoint in the NBA API is designed to provide comprehensive career statistics for individual NBA players. This endpoint is particularly valuable for several reasons:

  • Key parameter: player_id (the unique identifier for a player).

  • It returns a player's career statistics across different seasons and teams.


Python Code:

from nba_api.stats.endpoints import playercareerstats 
player_career = playercareerstats.PlayerCareerStats(player_id='2544') player_career_df = player_career.get_data_frames()[0]

Use Case: You could analyze a player's career progression, compare performance across seasons, evaluate improvements or declines in various statistical categories (e.g., points per game, field goal percentage), and understand a player's impact on different teams.



2.) Live Scoreboard Data (scoreboard)


The scoreboard endpoint in the NBA API is designed to provide real-time or recent data about NBA games, including scores, game statuses, and team information. This endpoint is particularly interesting for several reasons:

  • Accessed using the ScoreBoard class from the nba_api.live.nba.endpoints module.

  • Parameters can include specific dates or periods for live game data.

  • This endpoint provides real-time scores, game statuses, and team details.


Python Code:

from nba_api.live.nba.endpoints import scoreboard 
games = scoreboard.ScoreBoard() 
games_data = games.games.data

Use Case: This endpoint is ideal for real-time analyses, like tracking game scores, understanding momentum shifts in a game, and live tweeting or blogging about games.


  1. Live Game Updates: It offers real-time information on ongoing games, which is crucial for fans who want to stay updated on the latest scores and game developments.

  2. Game Details: The endpoint provides essential details about each game, such as the teams playing, scores, and the current status of the game (e.g., if it's in progress, finished, or yet to start).

  3. Scheduling Information: You can also obtain information about the dates and times of games, which is helpful for fans and analysts planning to watch or review games.

  4. Matchup Insights: The endpoint includes data on the home and away teams, allowing for analysis of team performance in different venues or under varying conditions.


3.) Team Information (teaminfocommon)


The commonteamroster endpoint in the NBA API provides detailed information about a team's roster for a specific season. This data is particularly interesting for analyzing team composition, player details, and understanding the makeup of a team during that season. Here are key aspects of this endpoint and what makes it interesting:

  • Key parameter: team_id (unique identifier for a team).

  • It provides detailed information about a specific NBA team, including seasonal statistics.


Python Code:

from nba_api.stats.endpoints import teaminfocommon 
lakers_info = teaminfocommon.TeamInfoCommon(team_id=1610612747) 
lakers_info_df = lakers_info.get_data_frames()[0]

Use Case: Analyze team performance over seasons, understand historical team data, and compare team stats in different eras.


4.) NBA Draft History (drafthistory)


The drafthistory endpoint in the NBA API is designed to provide historical data on the NBA Draft. This endpoint is particularly useful for those interested in analyzing draft trends, player selections, and the history of player entries into the NBA. Here's what makes the drafthistory endpoint noteworthy:

  • Parameters can include year, round, team, and college.

  • This endpoint gives historical data about NBA drafts, including player and team details.


Python Code:

from nba_api.stats.endpoints import drafthistory 
draft_history = drafthistory.DraftHistory() 
draft_history_df = draft_history.get_data_frames()[0]
draft_history_df

Use Case: Evaluate draft picks over the years, analyze the success rate of different draft rounds, and study trends in drafting from colleges or overseas.



5.) Shot Chart Details (shotchartdetail)


The shotchartdetail endpoint in the NBA API is a specialized tool for analyzing detailed shot data for individual players or teams. This endpoint is particularly intriguing for several reasons:

  • Key parameters: player_id and team_id.

  • Provides detailed shot chart data for a specific player, including location and outcome of each shot.


Python Code:

from nba_api.stats.endpoints import shotchartdetail curry_shot_chart = shotchartdetail.ShotChartDetail(player_id='201939', team_id=0) curry_shot_chart_df = curry_shot_chart.get_data_frames()[0]

Use Case: Create visual shot charts to analyze a player's shooting efficiency from different court areas, understand shooting patterns, and compare shooting performance in different games or seasons. This one has lots of good data, not all were able to be captured in the image below.


  1. Detailed Shot Location Data: It provides granular data on every shot attempt, including the location on the court where each shot was taken. This allows for an in-depth analysis of shooting patterns and preferences.

  2. Player or Team Specific: The endpoint can be queried for a specific player or team, offering tailored insights into their shooting performance.

  3. Visualization Potential: The data from this endpoint is ideal for creating shot charts, which visually represent a player's or team's shooting performance from different areas of the court. We'll demonstrate this in later posts.



6.) League Dash Player Clutch (leaguedashplayerclutch)


The leaguedashplayerclutch endpoint from the NBA API provides data specifically about players' performances in clutch situations. In basketball, "clutch" generally refers to how players perform during critical moments of the game, typically in the last few minutes of a close game. The data from this endpoint is tailored to reflect player performances under these high-pressure situations.


  • Parameters include season, player ID, team ID, and various filters to refine clutch performance data.

  • Returns data about players' performance in clutch moments of games.


Python Code:

from nba_api.stats.endpoints import leaguedashplayerclutch clutch_stats = leaguedashplayerclutch.LeagueDashPlayerClutch(season='2022-23') clutch_stats_df = clutch_stats.get_data_frames()[0]

Use Case: Identify key clutch players, analyze performance under pressure, and compare clutch performance among players or across seasons.



Here are a few of the clutch metrics that are interesting to consider for further analysis:

  1. MIN (Minutes): Indicates how much time a player spends on the court during clutch moments. A higher value can signify a player's importance in critical game situations.

  2. PTS (Points Scored): Shows the total points a player scores in clutch situations. Players who score more in these moments are often key offensive contributors.

  3. FGM (Field Goals Made) & FGA (Field Goals Attempted): These metrics provide insight into a player's shooting efficiency and volume during clutch moments.

  4. FG_PCT (Field Goal Percentage): This is crucial for understanding a player's shooting effectiveness under pressure.

  5. FG3M (3-Point Field Goals Made) & FG3A (3-Point Field Goals Attempted): Given the importance of three-point shooting in modern basketball, these stats indicate a player's ability to make long-range shots in clutch scenarios.

  6. FTM (Free Throws Made) & FTA (Free Throws Attempted): Clutch moments often involve critical free throws. These stats show how often a player gets to the line and their efficiency.


7.) Common Team Roster (commonteamroster)


The commonteamroster endpoint in the NBA API provides detailed information about a team's roster for a specific season. This data is particularly interesting for analyzing team composition, player details, and understanding the makeup of a team during that season. Here are key aspects of this endpoint and what makes it interesting:

  • Key parameters: season and team_id.


Python Code:

from nba_api.stats.endpoints import commonteamroster team_roster = commonteamroster.CommonTeamRoster(season='2022-23', team_id=1610612748) team_roster_df = team_roster.get_data_frames()[0]

Use Case: Understand team composition, analyze player roles based on position and experience, and study team building strategies over seasons.



A few of the use-cases for this endpoint:

  1. Team Composition Analysis: This endpoint allows for an in-depth look at the entire roster of a team, offering insights into the balance between positions, experience levels, and the mix of talent.

  2. Player Details: It includes comprehensive data on each player, such as height, weight, position, and experience. This can be useful for understanding the physical attributes and roles of players within the team.

  3. Youth vs. Experience: The endpoint includes data on players' experience and age, offering a perspective on the team's reliance on veterans versus young talent.

  4. Player Acquisition: It shows how each player was acquired by the team (e.g., draft, trade, free agency), which can be intriguing for understanding a team's strategy and front office decision-making.

8.) Player Game Logs (playergamelog)


The playergamelog endpoint in the NBA API is a valuable resource for analyzing individual player performance on a game-by-game basis. This endpoint provides detailed statistics for each game played by a specific player during a selected season. Here's what makes the playergamelog endpoint particularly interesting:

  • Key parameters: player_id and season.

  • Returns detailed game-by-game performance statistics for a player.


Python Code:

from nba_api.stats.endpoints import playergamelog 
player_logs = playergamelog.PlayerGameLog(player_id='203507', season='2022-23') 
player_logs_df = player_logs.get_data_frames()[0]
player_logs_df 

Use Case: Track a player's performance over a season, identify trends or patterns in performance, and compare game-to-game variations.


  1. Detailed Game-by-Game Performance: It offers a comprehensive look at a player's performance in each game, including scoring, rebounding, assists, and more. This is crucial for understanding a player's consistency and identifying patterns or trends in their performance.

  2. Season Trends and Patterns: By examining the data across multiple games, you can identify periods of peak performance, slumps, and how a player may be affected by factors like travel, opponent strength, or injuries.

  3. Statistical Breakdown: The endpoint provides various statistical categories such as points scored (PTS), assists (AST), rebounds (REB), field goal percentage (FG_PCT), and more, allowing for a multifaceted analysis of a player's game.


9.) League Leaders (leagueleaders)


The LeagueLeaders endpoint in the NBA API is a valuable tool for identifying the top-performing players across the NBA in various statistical categories for a given season. Here are key aspects of this endpoint and what makes it particularly interesting:

  • Parameters include the season, stat category, and other optional filters.

  • Provides data about the top players in various statistical categories for a season.


Python Code:

from nba_api.stats.endpoints import leagueleaders 
season_leaders = leagueleaders.LeagueLeaders(season='2022-23') 
season_leaders_df = season_leaders.get_data_frames()[0]
season_leaders_df

Use Case: Identify top-performing players in various statistical categories, compare players across different teams, and analyze the impact of leading players on their teams' performance.


  1. Ranking of Players: Players are ranked based on their performance in each statistical category, offering a clear view of who the top performers are in each area.

  2. Identifying Elite Players: The endpoint is particularly useful for identifying the league's elite players, who excel in one or more statistical areas. These players often have a significant impact on their teams and are frequently candidates for awards and honors.

  3. Historical Context and Comparisons: By examining data from this endpoint over multiple seasons, you can gain historical context and make comparisons to understand how players' performances have evolved over time.

The above explains many of the NBA API endpoints. Each of these endpoints offers unique data on the game, whether it's player-focused, team-focused, or game-focused. The data can be used for a wide range of analyses, from simple comparisons and trend analyses to more complex statistical models and predictive analytics.


Happy data-ing! Reach out if you have ideas for use-cases for these end points. We would love to hear how you're using them.

69 views0 comments

Recent Posts

See All
bottom of page