Overview
Thenew_tracking.py script collects player tracking statistics from NBA.com’s tracking endpoints. It gathers data across 8 different tracking categories including drives, catch-and-shoot, passing, possessions/touches, and location-specific touches.
Data Sources
- NBA.com Tracking API:
leaguedashptstatsendpoint - Tracking Categories:
- Drives
- Catch & Shoot
- Passing
- Possessions (touches)
- Elbow Touches
- Post Touches
- Paint Touches
- Pull-Up Shots
Core Function
get_tracking()
Collects tracking data for all categories across specified years.List of years to collect (e.g.,
[2024, 2025])Playoffs mode - if True, fetches playoff data
Tracking Categories
Drives
Number of drives to the basket
Field goals made on drives
Field goal attempts on drives
Field goal percentage on drives
Free throw percentage on drive attempts
Points scored on drives
Passes made during drives
Assists generated from drives
Turnovers on drives
Personal fouls drawn on drives
Catch & Shoot
Catch-and-shoot field goals made
Catch-and-shoot field goal attempts
Catch-and-shoot field goal percentage
Points from catch-and-shoot situations
Catch-and-shoot three-pointers made
Catch-and-shoot three-point attempts
Catch-and-shoot three-point percentage
Passing
Total passes made
Total passes received
Assists
Secondary assists (pass to the assister)
Potential assists (pass led to shot attempt)
Points created from assists
Adjusted assists (accounts for shot difficulty)
Possessions (Touches)
Number of times player touched the ball
Touches in front court
Time of possession (seconds)
Average seconds per touch
Average dribbles per touch
Points per touch
Touches at the elbow
Touches in the post
Touches in the paint
Pull-Up Shots
Pull-up field goals made
Pull-up field goal attempts
Pull-up field goal percentage
Points from pull-up shots
Pull-up three-pointers made
Pull-up three-point attempts
Output Files
Each tracking category has its own file:Drive statisticsPath:
tracking/drives.csv or tracking_ps/drives.csvCatch-and-shoot statisticsPath:
tracking/catchshoot.csvPassing and assist statisticsPath:
tracking/passing.csvPossession and touch statisticsPath:
tracking/touches.csvElbow touch statisticsPath:
tracking/elbow.csvPost touch statisticsPath:
tracking/post.csvPaint touch statisticsPath:
tracking/paint.csvPull-up shot statisticsPath:
tracking/pullup.csvFile Management
Usage Example
Historical Data Management
The script updates existing files by:- Reading old data
- Filtering out the current year (to avoid duplicates)
- Concatenating new data
- Saving updated file
Analysis Use Cases
- Offensive role identification: Drives vs catch-and-shoot vs pull-up shot distribution
- Playmaking evaluation: Passing metrics, secondary assists, potential assists
- Ball dominance: Touches, time of possession, dribbles per touch
- Location tendencies: Elbow, post, and paint touches
- Shot creation: Pull-up vs catch-and-shoot percentages