mirror of
https://github.com/nprasad2077/nbaStats.git
synced 2026-11-05 01:25:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b578cf94c | ||
|
|
0c20bb299b | ||
|
|
98cd5950b3 | ||
|
|
792155da49 | ||
|
|
34f9faaeb9 | ||
|
|
066c943066 | ||
|
|
aa785ede20 | ||
|
|
0469ac6053 | ||
|
|
512481f78b | ||
|
|
29e1e7a350 | ||
|
|
dd67c2a248 | ||
|
|
ce3641b970 | ||
|
|
878f8b549c | ||
|
|
1a3338ca68 | ||
|
|
c575b4a74d | ||
|
|
c664c9177d | ||
|
|
a5db9d1110 | ||
|
|
dc9b0df5be | ||
|
|
0dd41194d6 | ||
|
|
240449903c | ||
|
|
ea5b535d50 | ||
|
|
b38acd64cb | ||
|
|
204cc1a00d | ||
|
|
150bda67ca | ||
|
|
395f15683a | ||
|
|
8010111e82 | ||
|
|
caa97b109a | ||
|
|
030cfcd1d9 | ||
|
|
ae1b6a49f8 | ||
|
|
405d3d0356 | ||
|
|
fcfb8eadbe | ||
|
|
ff8084966a | ||
|
|
0e04f29d37 | ||
|
|
31ee84dfe8 | ||
|
|
f7fceb12fa | ||
|
|
13132473b1 | ||
|
|
45206c38bb | ||
|
|
9117807179 | ||
|
|
84f449b1e4 | ||
|
|
01604850ce | ||
|
|
00d8fdcf23 |
No files matched your search
@@ -1,464 +1,373 @@
|
|||||||
# NBA Stats API 0.1 Beta
|
# NBA Stats API 2.0
|
||||||
|
|
||||||
## Introduction
|
## [🔎 📜 View the Interactive API Documentation](https://api.server.nbaapi.com/)
|
||||||
|
|
||||||
This documentation provides the necessary information to use the NBA Stats API. These APIs provide access to NBA season and playoff totals, advanced statistics, shot chart data, and more.
|
[<img src="https://run.pstmn.io/button.svg" alt="Run In Postman" style="width: 128px; height: 32px;">](https://solar-meadow-682296.docs.buildwithfern.com)
|
||||||
|
|
||||||
|
|
||||||
|
# NEW DATA AVAILABLE SOON.
|
||||||
|
|
||||||
|
Hi Folks, stay tuned for new updated including much more advanced and refined player, game, and team statistics.
|
||||||
|
|
||||||
|
Here is a small preview:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
| API Responses |
|
||||||
|
| :---: |
|
||||||
|
| <img src="https://files.catbox.moe/sfi5z7.png" width="100%"> |
|
||||||
|
| <img src="https://files.catbox.moe/ua8jmc.png" width="100%"> |
|
||||||
|
| <img src="https://files.catbox.moe/no1mpw.png" width="100%"> |
|
||||||
|
| <img src="https://files.catbox.moe/ol7sjl.png" width="100%"> |
|
||||||
|
| <img src="https://files.catbox.moe/xi66gb.png" width="100%"> |
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
## 📺 Video Preview
|
||||||
|
|
||||||
|
<video src="https://github.com/user-attachments/assets/1e528ea9-7913-4e16-a33b-3251a0bb3c46" autoplay loop muted playsinline width="100%" type="video/mp4"></video>
|
||||||
|
|
||||||
|
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" height="4px" display="block">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Base URL
|
## Introduction
|
||||||
|
|
||||||
All URLs referenced in this documentation use the following base URL:
|
This documentation provides comprehensive information for using the NBA Stats API. The API offers access to NBA season and playoff statistics, including player totals, advanced metrics, and historical data. All statistics are cross-referenced with [basketball-reference.com](https://www.basketball-reference.com/) and [NBA.com](https://www.nba.com/stats).
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/
|
# NBA Player Statistics API
|
||||||
|
|
||||||
### Endpoints
|
This API provides endpoints to query NBA player statistics, including both "Totals" data, "Advanced" statistical data, and Player Shot Chart data. Each endpoint supports filtering, sorting, and pagination options to help you retrieve exactly the data you need.
|
||||||
|
|
||||||
Top 20 Scorers by Season
|
## Base URL
|
||||||
Method: `Get`
|
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/total/season/2023/
|
All API endpoints are served from:
|
||||||
|
|
||||||
Success Response:
|
|
||||||
|
|
||||||
`Code: 200`
|
|
||||||
|
|
||||||
Content:
|
|
||||||
```
|
```
|
||||||
|
https://api.server.nbaapi.com/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Authentication
|
||||||
|
|
||||||
|
No authentication is currently required for these endpoints.
|
||||||
|
|
||||||
|
## Available Endpoints
|
||||||
|
|
||||||
|
- **Player Advanced Stats** (`/api/playeradvancedstats`)
|
||||||
|
|
||||||
|
Provides advanced player metrics including Player Efficiency Rating (PER), True Shooting Percentage (TS%), Usage Percentage, Win Shares, VORP, and other advanced analytics.
|
||||||
|
|
||||||
|
- **Player Totals** (`/api/playertotals`)
|
||||||
|
|
||||||
|
Provides season-based totals such as points, assists, rebounds, games played, shooting percentages, and more traditional statistics.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Common Query Parameters
|
||||||
|
|
||||||
|
Both endpoints support the following query parameters:
|
||||||
|
|
||||||
|
### Filtering Parameters
|
||||||
|
- **season** *(integer, optional)*: Filter by a specific season (e.g., `2025`)
|
||||||
|
- **team** *(string, optional)*: Filter by team abbreviation (e.g., `MIL`, `LAL`)
|
||||||
|
- **playerId** *(string, optional)*: Filter by player's unique ID (e.g., `greenaj01`)
|
||||||
|
- **isPlayoff** *(boolean, optional)*: Filter for playoff statistics (`true`) or regular season (`false`)
|
||||||
|
|
||||||
|
### Pagination Parameters
|
||||||
|
- **page** *(integer, optional)*: Page number to retrieve (default: `1`)
|
||||||
|
- **pageSize** *(integer, optional)*: Number of records per page (default: `20`)
|
||||||
|
|
||||||
|
### Sorting Parameters
|
||||||
|
- **sortBy** *(string, optional)*: Field name to sort results by (see endpoint-specific options below)
|
||||||
|
- **ascending** *(boolean, optional)*: Sort order - `true` for ascending, `false` for descending (default: `false`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Player Advanced Stats Endpoint
|
||||||
|
|
||||||
|
**GET** `/api/playeradvancedstats`
|
||||||
|
|
||||||
|
Retrieve advanced player statistics with comprehensive filtering and sorting options.
|
||||||
|
|
||||||
|
### Sorting Options for Advanced Stats
|
||||||
|
|
||||||
|
The `sortBy` parameter accepts the following values:
|
||||||
|
- `games` - Games played
|
||||||
|
- `minutes_played` - Total minutes played
|
||||||
|
- `ts_percent` - True Shooting Percentage
|
||||||
|
- `total_rb_percent` - Total Rebound Percentage
|
||||||
|
- `usage_percent` - Usage Percentage
|
||||||
|
- `offensive_ws` - Offensive Win Shares
|
||||||
|
- `defensive_ws` - Defensive Win Shares
|
||||||
|
- `win_shares` - Total Win Shares (default)
|
||||||
|
- `win_shares_per` - Win Shares per 48 minutes
|
||||||
|
- `offensive_box` - Offensive Box Plus/Minus
|
||||||
|
- `defensive_box` - Defensive Box Plus/Minus
|
||||||
|
- `box` - Total Box Plus/Minus
|
||||||
|
- `vorp` - Value Over Replacement Player
|
||||||
|
- `season` - Season year
|
||||||
|
|
||||||
|
### Example Request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playeradvancedstats?page=1&pageSize=20&sortBy=win_shares&ascending=false&season=2025&team=MIL' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Response Format
|
||||||
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
"count": 20,
|
"data": [
|
||||||
"next": null,
|
|
||||||
"previous": null,
|
|
||||||
"results": [
|
|
||||||
{
|
{
|
||||||
"id": 40,
|
"id": 12345,
|
||||||
"player_name": "Jayson Tatum",
|
"playerName": "Giannis Antetokounmpo",
|
||||||
"age": 24,
|
"position": "PF",
|
||||||
"games": 74,
|
"age": 30,
|
||||||
"games_started": 74,
|
"games": 65,
|
||||||
"minutes_played": 2732,
|
"minutesPlayed": 2205,
|
||||||
"field_goals": 727,
|
"per": 31.2,
|
||||||
"field_attempts": 1559,
|
"tsPercent": 0.614,
|
||||||
"field_percent": "0.466",
|
"threePAR": 0.156,
|
||||||
"three_fg": 240,
|
"ftr": 0.345,
|
||||||
"three_attempts": 686,
|
"offensiveRBPercent": 11.2,
|
||||||
"three_percent": "0.350",
|
"defensiveRBPercent": 34.5,
|
||||||
"two_fg": 487,
|
"totalRBPercent": 22.8,
|
||||||
"two_attempts": 873,
|
"assistPercent": 40.1,
|
||||||
"two_percent": "0.558",
|
"stealPercent": 1.8,
|
||||||
"effect_fg_percent": "0.543",
|
"blockPercent": 3.2,
|
||||||
"ft": 531,
|
"turnoverPercent": 16.7,
|
||||||
"fta": 622,
|
"usagePercent": 36.8,
|
||||||
"ft_percent": "0.854",
|
"offensiveWS": 12.3,
|
||||||
"ORB": 78,
|
"defensiveWS": 4.7,
|
||||||
"DRB": 571,
|
"winShares": 17.0,
|
||||||
"TRB": 649,
|
"winSharesPer": 0.370,
|
||||||
"AST": 342,
|
"offensiveBox": 8.9,
|
||||||
"STL": 78,
|
"defensiveBox": 2.1,
|
||||||
"BLK": 51,
|
"box": 11.0,
|
||||||
"TOV": 213,
|
"vorp": 9.2,
|
||||||
"PF": 160,
|
"team": "MIL",
|
||||||
"PTS": 2225,
|
"season": 2025,
|
||||||
"team": "BOS",
|
"playerId": "antetgi01",
|
||||||
"season": 2023
|
"isPlayoff": false
|
||||||
},
|
}
|
||||||
{
|
],
|
||||||
"id": 20,
|
"pagination": {
|
||||||
"player_name": "Joel Embiid",
|
"page": 1,
|
||||||
"age": 28,
|
"pageSize": 20,
|
||||||
"games": 66,
|
"total": 450,
|
||||||
"games_started": 66,
|
"pages": 23
|
||||||
"minutes_played": 2284,
|
}
|
||||||
"field_goals": 728,
|
|
||||||
"field_attempts": 1328,
|
|
||||||
"field_percent": "0.548",
|
|
||||||
"three_fg": 66,
|
|
||||||
"three_attempts": 200,
|
|
||||||
"three_percent": "0.330",
|
|
||||||
"two_fg": 662,
|
|
||||||
"two_attempts": 1128,
|
|
||||||
"two_percent": "0.587",
|
|
||||||
"effect_fg_percent": "0.573",
|
|
||||||
"ft": 661,
|
|
||||||
"fta": 771,
|
|
||||||
"ft_percent": "0.857",
|
|
||||||
"ORB": 113,
|
|
||||||
"DRB": 557,
|
|
||||||
"TRB": 670,
|
|
||||||
"AST": 274,
|
|
||||||
"STL": 66,
|
|
||||||
"BLK": 112,
|
|
||||||
"TOV": 226,
|
|
||||||
"PF": 205,
|
|
||||||
"PTS": 2183,
|
|
||||||
"team": "PHI",
|
|
||||||
"season": 2023
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Top 20 Scorers in Playoffs
|
---
|
||||||
Method: `Get`
|
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/playoffs/2022/
|
## Player Totals Endpoint
|
||||||
|
|
||||||
Success Response:
|
**GET** `/api/playertotals`
|
||||||
|
|
||||||
`Code: 200`
|
Retrieve traditional player statistics including points, assists, rebounds, and shooting data.
|
||||||
|
|
||||||
Content:
|
### Sorting Options for Player Totals
|
||||||
|
|
||||||
|
The `sortBy` parameter accepts the following values:
|
||||||
|
- `games` - Games played
|
||||||
|
- `minutes_pg` - Minutes per game
|
||||||
|
- `three_fg` - Three-point field goals made
|
||||||
|
- `three_attempts` - Three-point field goal attempts
|
||||||
|
- `two_fg` - Two-point field goals made
|
||||||
|
- `effect_fg_percent` - Effective Field Goal Percentage
|
||||||
|
- `ft` - Free throws made
|
||||||
|
- `total_rb` - Total rebounds
|
||||||
|
- `assists` - Assists
|
||||||
|
- `steals` - Steals
|
||||||
|
- `blocks` - Blocks
|
||||||
|
- `points` - Points scored
|
||||||
|
- `season` - Season year
|
||||||
|
|
||||||
|
### Example Request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playertotals?page=1&pageSize=20&sortBy=points&ascending=false&season=2025' \
|
||||||
|
-H 'accept: application/json'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Response Format
|
||||||
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
"count": 20,
|
"data": [
|
||||||
"next": null,
|
|
||||||
"previous": null,
|
|
||||||
"results": [
|
|
||||||
{
|
{
|
||||||
"id": 16,
|
"id": 67890,
|
||||||
"player_name": "Jayson Tatum",
|
"playerName": "Luka Doncic",
|
||||||
"age": 23,
|
"position": "PG",
|
||||||
"games": 24,
|
|
||||||
"games_started": 24,
|
|
||||||
"minutes_played": 983,
|
|
||||||
"field_goals": 201,
|
|
||||||
"field_attempts": 472,
|
|
||||||
"field_percent": "0.426",
|
|
||||||
"three_fg": 77,
|
|
||||||
"three_attempts": 196,
|
|
||||||
"three_percent": "0.393",
|
|
||||||
"two_fg": 124,
|
|
||||||
"two_attempts": 276,
|
|
||||||
"two_percent": "0.449",
|
|
||||||
"effect_fg_percent": "0.507",
|
|
||||||
"ft": 136,
|
|
||||||
"fta": 170,
|
|
||||||
"ft_percent": "0.800",
|
|
||||||
"ORB": 24,
|
|
||||||
"DRB": 137,
|
|
||||||
"TRB": 161,
|
|
||||||
"AST": 148,
|
|
||||||
"STL": 29,
|
|
||||||
"BLK": 21,
|
|
||||||
"TOV": 100,
|
|
||||||
"PF": 72,
|
|
||||||
"PTS": 615,
|
|
||||||
"team": "BOS",
|
|
||||||
"season": 2022
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 178,
|
|
||||||
"player_name": "Stephen Curry",
|
|
||||||
"age": 33,
|
|
||||||
"games": 22,
|
|
||||||
"games_started": 18,
|
|
||||||
"minutes_played": 764,
|
|
||||||
"field_goals": 202,
|
|
||||||
"field_attempts": 440,
|
|
||||||
"field_percent": "0.459",
|
|
||||||
"three_fg": 91,
|
|
||||||
"three_attempts": 229,
|
|
||||||
"three_percent": "0.397",
|
|
||||||
"two_fg": 111,
|
|
||||||
"two_attempts": 211,
|
|
||||||
"two_percent": "0.526",
|
|
||||||
"effect_fg_percent": "0.563",
|
|
||||||
"ft": 107,
|
|
||||||
"fta": 129,
|
|
||||||
"ft_percent": "0.829",
|
|
||||||
"ORB": 11,
|
|
||||||
"DRB": 104,
|
|
||||||
"TRB": 115,
|
|
||||||
"AST": 129,
|
|
||||||
"STL": 29,
|
|
||||||
"BLK": 8,
|
|
||||||
"TOV": 57,
|
|
||||||
"PF": 59,
|
|
||||||
"PTS": 602,
|
|
||||||
"team": "GSW",
|
|
||||||
"season": 2022
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Top 20 Assists by Season
|
|
||||||
Method: `Get`
|
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_assists/totals/2023/
|
|
||||||
|
|
||||||
Success Response:
|
|
||||||
|
|
||||||
`Code: 200`
|
|
||||||
|
|
||||||
Content:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"count": 20,
|
|
||||||
"next": null,
|
|
||||||
"previous": null,
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"id": 529,
|
|
||||||
"player_name": "Trae Young",
|
|
||||||
"age": 24,
|
|
||||||
"games": 73,
|
|
||||||
"games_started": 73,
|
|
||||||
"minutes_played": 2541,
|
|
||||||
"field_goals": 597,
|
|
||||||
"field_attempts": 1390,
|
|
||||||
"field_percent": "0.429",
|
|
||||||
"three_fg": 154,
|
|
||||||
"three_attempts": 460,
|
|
||||||
"three_percent": "0.335",
|
|
||||||
"two_fg": 443,
|
|
||||||
"two_attempts": 930,
|
|
||||||
"two_percent": "0.476",
|
|
||||||
"effect_fg_percent": "0.485",
|
|
||||||
"ft": 566,
|
|
||||||
"fta": 639,
|
|
||||||
"ft_percent": "0.886",
|
|
||||||
"ORB": 56,
|
|
||||||
"DRB": 161,
|
|
||||||
"TRB": 217,
|
|
||||||
"AST": 741,
|
|
||||||
"STL": 80,
|
|
||||||
"BLK": 9,
|
|
||||||
"TOV": 300,
|
|
||||||
"PF": 104,
|
|
||||||
"PTS": 1914,
|
|
||||||
"team": "ATL",
|
|
||||||
"season": 2023
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 203,
|
|
||||||
"player_name": "Nikola Jokić",
|
|
||||||
"age": 27,
|
|
||||||
"games": 69,
|
|
||||||
"games_started": 69,
|
|
||||||
"minutes_played": 2323,
|
|
||||||
"field_goals": 646,
|
|
||||||
"field_attempts": 1022,
|
|
||||||
"field_percent": "0.632",
|
|
||||||
"three_fg": 57,
|
|
||||||
"three_attempts": 149,
|
|
||||||
"three_percent": "0.383",
|
|
||||||
"two_fg": 589,
|
|
||||||
"two_attempts": 873,
|
|
||||||
"two_percent": "0.675",
|
|
||||||
"effect_fg_percent": "0.660",
|
|
||||||
"ft": 341,
|
|
||||||
"fta": 415,
|
|
||||||
"ft_percent": "0.822",
|
|
||||||
"ORB": 167,
|
|
||||||
"DRB": 650,
|
|
||||||
"TRB": 817,
|
|
||||||
"AST": 678,
|
|
||||||
"STL": 87,
|
|
||||||
"BLK": 47,
|
|
||||||
"TOV": 247,
|
|
||||||
"PF": 174,
|
|
||||||
"PTS": 1690,
|
|
||||||
"team": "DEN",
|
|
||||||
"season": 2023
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Top 20 Assists in Playoffs
|
|
||||||
Method: `Get`
|
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_assists/playoffs/2022/
|
|
||||||
|
|
||||||
|
|
||||||
Success Response:
|
|
||||||
|
|
||||||
`Code: 200`
|
|
||||||
|
|
||||||
Content:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"count": 20,
|
|
||||||
"next": null,
|
|
||||||
"previous": null,
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"id": 16,
|
|
||||||
"player_name": "Jayson Tatum",
|
|
||||||
"age": 23,
|
|
||||||
"games": 24,
|
|
||||||
"games_started": 24,
|
|
||||||
"minutes_played": 983,
|
|
||||||
"field_goals": 201,
|
|
||||||
"field_attempts": 472,
|
|
||||||
"field_percent": "0.426",
|
|
||||||
"three_fg": 77,
|
|
||||||
"three_attempts": 196,
|
|
||||||
"three_percent": "0.393",
|
|
||||||
"two_fg": 124,
|
|
||||||
"two_attempts": 276,
|
|
||||||
"two_percent": "0.449",
|
|
||||||
"effect_fg_percent": "0.507",
|
|
||||||
"ft": 136,
|
|
||||||
"fta": 170,
|
|
||||||
"ft_percent": "0.800",
|
|
||||||
"ORB": 24,
|
|
||||||
"DRB": 137,
|
|
||||||
"TRB": 161,
|
|
||||||
"AST": 148,
|
|
||||||
"STL": 29,
|
|
||||||
"BLK": 21,
|
|
||||||
"TOV": 100,
|
|
||||||
"PF": 72,
|
|
||||||
"PTS": 615,
|
|
||||||
"team": "BOS",
|
|
||||||
"season": 2022
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 179,
|
|
||||||
"player_name": "Draymond Green",
|
|
||||||
"age": 31,
|
|
||||||
"games": 22,
|
|
||||||
"games_started": 22,
|
|
||||||
"minutes_played": 703,
|
|
||||||
"field_goals": 69,
|
|
||||||
"field_attempts": 144,
|
|
||||||
"field_percent": "0.479",
|
|
||||||
"three_fg": 8,
|
|
||||||
"three_attempts": 39,
|
|
||||||
"three_percent": "0.205",
|
|
||||||
"two_fg": 61,
|
|
||||||
"two_attempts": 105,
|
|
||||||
"two_percent": "0.581",
|
|
||||||
"effect_fg_percent": "0.507",
|
|
||||||
"ft": 30,
|
|
||||||
"fta": 47,
|
|
||||||
"ft_percent": "0.638",
|
|
||||||
"ORB": 26,
|
|
||||||
"DRB": 133,
|
|
||||||
"TRB": 159,
|
|
||||||
"AST": 138,
|
|
||||||
"STL": 25,
|
|
||||||
"BLK": 22,
|
|
||||||
"TOV": 59,
|
|
||||||
"PF": 87,
|
|
||||||
"PTS": 176,
|
|
||||||
"team": "GSW",
|
|
||||||
"season": 2022
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Top 20 Rebounders (Total Rebounds) by Season
|
|
||||||
Method: `Get`
|
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_rebounds/totals/2023/
|
|
||||||
|
|
||||||
Success Response:
|
|
||||||
|
|
||||||
`Code: 200`
|
|
||||||
|
|
||||||
Content:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"count": 20,
|
|
||||||
"next": null,
|
|
||||||
"previous": null,
|
|
||||||
"results": [
|
|
||||||
{
|
|
||||||
"id": 405,
|
|
||||||
"player_name": "Domantas Sabonis",
|
|
||||||
"age": 26,
|
"age": 26,
|
||||||
"games": 79,
|
"games": 70,
|
||||||
"games_started": 79,
|
"gamesStarted": 70,
|
||||||
"minutes_played": 2736,
|
"minutesPg": 36.2,
|
||||||
"field_goals": 577,
|
"fieldGoals": 11.2,
|
||||||
"field_attempts": 938,
|
"fieldAttempts": 23.1,
|
||||||
"field_percent": "0.615",
|
"fieldPercent": 0.485,
|
||||||
"three_fg": 31,
|
"threeFg": 4.1,
|
||||||
"three_attempts": 83,
|
"threeAttempts": 11.3,
|
||||||
"three_percent": "0.373",
|
"threePercent": 0.363,
|
||||||
"two_fg": 546,
|
"twoFg": 7.1,
|
||||||
"two_attempts": 855,
|
"twoAttempts": 11.8,
|
||||||
"two_percent": "0.639",
|
"twoPercent": 0.602,
|
||||||
"effect_fg_percent": "0.632",
|
"effectFgPercent": 0.574,
|
||||||
"ft": 325,
|
"ft": 7.8,
|
||||||
"fta": 438,
|
"ftAttempts": 9.2,
|
||||||
"ft_percent": "0.742",
|
"ftPercent": 0.848,
|
||||||
"ORB": 251,
|
"offensiveRb": 1.8,
|
||||||
"DRB": 722,
|
"defensiveRb": 7.4,
|
||||||
"TRB": 973,
|
"totalRb": 9.2,
|
||||||
"AST": 573,
|
"assists": 8.9,
|
||||||
"STL": 65,
|
"steals": 1.4,
|
||||||
"BLK": 39,
|
"blocks": 0.5,
|
||||||
"TOV": 230,
|
"turnovers": 4.1,
|
||||||
"PF": 279,
|
"personalFouls": 2.8,
|
||||||
"PTS": 1510,
|
"points": 34.3,
|
||||||
"team": "SAC",
|
"team": "DAL",
|
||||||
"season": 2023
|
"season": 2025,
|
||||||
},
|
"playerId": "doncilu01",
|
||||||
{
|
"isPlayoff": false
|
||||||
"id": 346,
|
}
|
||||||
"player_name": "Nikola Vučević",
|
],
|
||||||
"age": 32,
|
"pagination": {
|
||||||
"games": 82,
|
"page": 1,
|
||||||
"games_started": 82,
|
"pageSize": 20,
|
||||||
"minutes_played": 2746,
|
"total": 500,
|
||||||
"field_goals": 597,
|
"pages": 25
|
||||||
"field_attempts": 1148,
|
}
|
||||||
"field_percent": "0.520",
|
|
||||||
"three_fg": 121,
|
|
||||||
"three_attempts": 347,
|
|
||||||
"three_percent": "0.349",
|
|
||||||
"two_fg": 476,
|
|
||||||
"two_attempts": 801,
|
|
||||||
"two_percent": "0.594",
|
|
||||||
"effect_fg_percent": "0.573",
|
|
||||||
"ft": 132,
|
|
||||||
"fta": 158,
|
|
||||||
"ft_percent": "0.835",
|
|
||||||
"ORB": 159,
|
|
||||||
"DRB": 744,
|
|
||||||
"TRB": 903,
|
|
||||||
"AST": 265,
|
|
||||||
"STL": 60,
|
|
||||||
"BLK": 57,
|
|
||||||
"TOV": 139,
|
|
||||||
"PF": 179,
|
|
||||||
"PTS": 1447,
|
|
||||||
"team": "CHI",
|
|
||||||
"season": 2023
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Plan
|
---
|
||||||
|
## Player Shot Chart Endpoint
|
||||||
|
|
||||||
1. Data collection - Selenium - live data from dyanic websites. - Beautiful soap/scrapy - historical static data. - Live data - websocket connections or periodic updates.
|
**GET** `/api/playershotchart`
|
||||||
|
|
||||||
|
|
||||||
2. Backend API - Django (Python): A more comprehensive framework that includes an ORM and admin panel out-of-the-box. - Django REST Framework
|
Retrieve shot chart data for a specific player. This endpoint is ideal for visualizing player shooting performance and can be filtered by game, season, shot type, and outcome.
|
||||||
|
|
||||||
|
|
||||||
3. Backend DB
|
### Query Parameters for Shot Chart
|
||||||
-Initially SQL lite, but it quickly met its limitations when trying to scrape data for 30 teams at once. It could not handle all the simulataneous connections.
|
|
||||||
|
|
||||||
- PostgreSQL is the new DB.
|
- **playerId** *(string, optional)*: The player's unique ID (e.g., `hardeja01`).
|
||||||
|
- **season** *(integer, optional)*: Filter by a specific season (e.g., `2019`).
|
||||||
|
- **date** *(string, optional)*: Filter by a specific game date (e.g., `Dec 17, 2018`).
|
||||||
|
- **opponent** *(string, optional)*: Filter by the three-letter abbreviation for the opponent team (e.g., `UTA`).
|
||||||
|
- **qtr** *(string, optional)*: Filter by the quarter of the game (e.g., `1st Qtr`).
|
||||||
|
- **result** *(boolean, optional)*: Filter by shot outcome (`true` for made shots, `false` for missed).
|
||||||
|
- **shot\_type** *(string, optional)*: Filter by the type of shot (e.g., `2-pointer`, `3-pointer`).
|
||||||
|
- **page** *(integer, optional)*: Page number to retrieve (default: `1`). Note: The page size is fixed at 50 results.
|
||||||
|
|
||||||
4. Frontend - React/Redux - D3.js - Chart.js - Highcharts - Websockets or Server-Sent Events
|
### Example Request
|
||||||
|
|
||||||
|
|
||||||
5. Deployment
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playershotchart?playerId=hardeja01&date=Dec%2017%2C2018' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Response Format
|
||||||
|
|
||||||
|
The response is an array of shot objects.
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 510,
|
||||||
|
"playerId": "hardeja01",
|
||||||
|
"season": 2019,
|
||||||
|
"date": "Dec 17,2018",
|
||||||
|
"qtr": "1st Qtr",
|
||||||
|
"timeRemaining": "11:09",
|
||||||
|
"top": 305,
|
||||||
|
"left": 161,
|
||||||
|
"playerName": "hardeja01",
|
||||||
|
"result": false,
|
||||||
|
"shotType": "3-pointer",
|
||||||
|
"distanceFt": 26,
|
||||||
|
"lead": true,
|
||||||
|
"teamScore": 3,
|
||||||
|
"opponentTeamScore": 0,
|
||||||
|
"opponent": "UTA",
|
||||||
|
"team": "HOU",
|
||||||
|
"ID": 0,
|
||||||
|
"CreatedAt": "2025-06-20T22:48:34.764255Z",
|
||||||
|
"UpdatedAt": "2025-06-20T22:48:34.764255Z",
|
||||||
|
"DeletedAt": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
## Response Codes
|
||||||
|
|
||||||
|
- **200 OK**: Request successful; returns requested data
|
||||||
|
- **400 Bad Request**: Invalid query parameters
|
||||||
|
- **404 Not Found**: No matching records found
|
||||||
|
- **500 Internal Server Error**: Server encountered an error
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
### Get Top Win Shares Leaders (Advanced Stats)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playeradvancedstats?page=1&pageSize=10&sortBy=win_shares&ascending=false&season=2025' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get Leading Scorers (Player Totals)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playertotals?page=1&pageSize=10&sortBy=points&ascending=false&season=2025' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get Boston Celtics Players Advanced Stats
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playeradvancedstats?team=BOS&season=2025&page=1&pageSize=20&sortBy=vorp&ascending=false' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get Playoff Statistics
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET \
|
||||||
|
'https://api.server.nbaapi.com/api/playertotals?isPlayoff=true&season=2024&sortBy=points&ascending=false' \
|
||||||
|
-H 'accept: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
- **Interactive Documentation**: [https://api.server.nbaapi.com](https://api.server.nbaapi.com/swagger/index.html)
|
||||||
|
- **Postman Collection**: Use the "Run in Postman" button above
|
||||||
|
- **Data Sources**: Statistics cross-referenced with Basketball Reference and NBA.com
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Contact & Support
|
||||||
|
|
||||||
|
If you encounter any issues or have questions about the API, please open an issue in the repository or contact the development team. 🏀🚀
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Note**: This API is currently in public beta. Features and endpoints may be updated based on user feedback and requirements.
|
||||||
@@ -27,7 +27,7 @@ from nba_data.models import PlayerPlayoffAdvancedData
|
|||||||
# Change LAC to SDC for 1984 and prior.
|
# Change LAC to SDC for 1984 and prior.
|
||||||
|
|
||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'BRK', 'TOR', 'MEM', 'NOP', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['ATL', 'BOS', 'BRK', 'CHI', 'CHO', 'CLE', 'DAL', 'DEN', 'DET', 'GSW', 'HOU', 'IND', 'LAC', 'LAL', 'MEM', 'MIA', 'MIL', 'MIN', 'NOP', 'NYK', 'OKC', 'ORL', 'PHI', 'PHO', 'POR', 'SAC', 'SAS', 'TOR', 'UTA', 'WAS']
|
||||||
|
|
||||||
single_team = ['GSW']
|
single_team = ['GSW']
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ django.setup()
|
|||||||
|
|
||||||
from nba_data.models import PlayerShotChartData
|
from nba_data.models import PlayerShotChartData
|
||||||
|
|
||||||
player_name = 'LeBron James'
|
player_name = 'James Harden'
|
||||||
season = 2014
|
season = 2010
|
||||||
# team = 'LAL' # You might want to find a way to get this from the webpage
|
# team = 'LAL' # You might want to find a way to get this from the webpage
|
||||||
url = 'https://www.basketball-reference.com/players/j/jamesle01/shooting/' + \
|
url = 'https://www.basketball-reference.com/players/h/hardeja01/shooting/' + \
|
||||||
str(season)
|
str(season)
|
||||||
|
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@@ -110,4 +110,4 @@ try:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error inserting data into database: {e}")
|
print(f"Error inserting data into database: {e}")
|
||||||
|
|
||||||
print('success')
|
print(f"success {player_name} {season}")
|
||||||
+8
-8
@@ -30,22 +30,22 @@ class PlayerDataByTeamList(generics.ListAPIView):
|
|||||||
return PlayerData.objects.filter(team=team)
|
return PlayerData.objects.filter(team=team)
|
||||||
|
|
||||||
|
|
||||||
# Fetch player data by season
|
# Fetch player totals data by season
|
||||||
class PlayerDataBySeasonList(generics.ListAPIView):
|
class PlayerDataBySeasonList(generics.ListAPIView):
|
||||||
serializer_class = PlayerDataSerializer
|
serializer_class = PlayerTotalsDataSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerData.objects.filter(season=season)
|
return PlayerTotalsData.objects.filter(season=season)
|
||||||
|
|
||||||
|
|
||||||
# Fetch player data by player name
|
# Fetch player totals data by player name
|
||||||
class PlayerDataByNameList(generics.ListAPIView):
|
class PlayerDataByNameList(generics.ListAPIView):
|
||||||
serializer_class = PlayerDataSerializer
|
serializer_class = PlayerTotalsDataSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
name = self.kwargs['name']
|
name = self.kwargs['name']
|
||||||
return PlayerData.objects.filter(name__icontains=name)
|
return PlayerTotalsData.objects.filter(player_name__icontains=name)
|
||||||
|
|
||||||
|
|
||||||
# Fetch Top 20 players by PTS DESC for the season specified.
|
# Fetch Top 20 players by PTS DESC for the season specified.
|
||||||
@@ -62,7 +62,7 @@ class TopScorersbySeasonTotalsList(generics.ListAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerTotalsData.objects.filter(season=season).order_by('-PTS')[:20]
|
return PlayerTotalsData.objects.filter(season=season).order_by('-PTS')[:200]
|
||||||
|
|
||||||
|
|
||||||
# Fetch and calculate the average 3P made, 3P attemps, 2P made, 2P attempts for all players in each season.
|
# Fetch and calculate the average 3P made, 3P attemps, 2P made, 2P attempts for all players in each season.
|
||||||
@@ -631,7 +631,7 @@ class TopScorersbySeasonListPlayoffs(generics.ListAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerPlayoffTotalsData.objects.filter(season=season).order_by('-PTS')[:20]
|
return PlayerPlayoffTotalsData.objects.filter(season=season).order_by('-PTS')[:200]
|
||||||
|
|
||||||
|
|
||||||
class TopAssistsBySeasonListPlayoffs(generics.ListAPIView):
|
class TopAssistsBySeasonListPlayoffs(generics.ListAPIView):
|
||||||
|
|||||||
Reference in new issue
Block a user