mirror of
https://github.com/nprasad2077/nbaStats.git
synced 2026-11-05 01:25:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eaa50f4e7 | ||
|
|
4b1d07353d | ||
|
|
0701ef19d2 | ||
|
|
3558b1c154 | ||
|
|
150bda67ca | ||
|
|
395f15683a | ||
|
|
8010111e82 | ||
|
|
caa97b109a | ||
|
|
030cfcd1d9 | ||
|
|
ae1b6a49f8 | ||
|
|
405d3d0356 | ||
|
|
fcfb8eadbe | ||
|
|
ff8084966a | ||
|
|
0e04f29d37 | ||
|
|
31ee84dfe8 | ||
|
|
f7fceb12fa | ||
|
|
13132473b1 | ||
|
|
45206c38bb | ||
|
|
9117807179 | ||
|
|
84f449b1e4 | ||
|
|
01604850ce | ||
|
|
00d8fdcf23 |
No files matched your search
@@ -6,24 +6,29 @@ This documentation provides the necessary information to use the NBA Stats API.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# [View API Documentation](https://documenter.getpostman.com/view/24232555/2s93shzpR3)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Base URL
|
### Base URL
|
||||||
|
|
||||||
All URLs referenced in this documentation use the following base URL:
|
All URLs referenced in this documentation use the following base URL:
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/
|
> <https://nba-stats-db.herokuapp.com/>
|
||||||
|
|
||||||
### Endpoints
|
### Endpoints
|
||||||
|
|
||||||
Top 20 Scorers by Season
|
Top 20 Scorers by Season
|
||||||
Method: `Get`
|
Method: `Get`
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/total/season/2023/
|
> <https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/total/season/2023/>
|
||||||
|
|
||||||
Success Response:
|
Success Response:
|
||||||
|
|
||||||
`Code: 200`
|
`Code: 200`
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"count": 20,
|
"count": 20,
|
||||||
@@ -103,13 +108,14 @@ Content:
|
|||||||
Top 20 Scorers in Playoffs
|
Top 20 Scorers in Playoffs
|
||||||
Method: `Get`
|
Method: `Get`
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/playoffs/2022/
|
> <https://nba-stats-db.herokuapp.com/api/playerdata/topscorers/playoffs/2022/>
|
||||||
|
|
||||||
Success Response:
|
Success Response:
|
||||||
|
|
||||||
`Code: 200`
|
`Code: 200`
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"count": 20,
|
"count": 20,
|
||||||
@@ -189,13 +195,14 @@ Content:
|
|||||||
Top 20 Assists by Season
|
Top 20 Assists by Season
|
||||||
Method: `Get`
|
Method: `Get`
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_assists/totals/2023/
|
> <https://nba-stats-db.herokuapp.com/api/top_assists/totals/2023/>
|
||||||
|
|
||||||
Success Response:
|
Success Response:
|
||||||
|
|
||||||
`Code: 200`
|
`Code: 200`
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"count": 20,
|
"count": 20,
|
||||||
@@ -275,14 +282,14 @@ Content:
|
|||||||
Top 20 Assists in Playoffs
|
Top 20 Assists in Playoffs
|
||||||
Method: `Get`
|
Method: `Get`
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_assists/playoffs/2022/
|
> <https://nba-stats-db.herokuapp.com/api/top_assists/playoffs/2022/>
|
||||||
|
|
||||||
|
|
||||||
Success Response:
|
Success Response:
|
||||||
|
|
||||||
`Code: 200`
|
`Code: 200`
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"count": 20,
|
"count": 20,
|
||||||
@@ -362,13 +369,14 @@ Content:
|
|||||||
Top 20 Rebounders (Total Rebounds) by Season
|
Top 20 Rebounders (Total Rebounds) by Season
|
||||||
Method: `Get`
|
Method: `Get`
|
||||||
|
|
||||||
> https://nba-stats-db.herokuapp.com/api/top_rebounds/totals/2023/
|
> <https://nba-stats-db.herokuapp.com/api/top_rebounds/totals/2023/>
|
||||||
|
|
||||||
Success Response:
|
Success Response:
|
||||||
|
|
||||||
`Code: 200`
|
`Code: 200`
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"count": 20,
|
"count": 20,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
teams_data = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOK', 'DAL', 'SAS', 'DEN', 'MIN', 'SEA', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
||||||
@@ -6,6 +6,7 @@ from bs4 import BeautifulSoup
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from data import teams_data
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
@@ -27,10 +28,11 @@ from nba_data.models import PlayerAdvancedData
|
|||||||
# Change MEM to VAN for 2001 and prior.
|
# Change MEM to VAN for 2001 and prior.
|
||||||
# Change LAC to SDC for 1984 and prior.
|
# Change LAC to SDC for 1984 and prior.
|
||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'SEA', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
||||||
|
|
||||||
season = input('What season? ')
|
season = input('What season? ')
|
||||||
|
|
||||||
for team in teams:
|
for team in teams_data:
|
||||||
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
||||||
response = requests.get(url_make)
|
response = requests.get(url_make)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from bs4 import BeautifulSoup
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from data import teams_data
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
@@ -29,13 +30,11 @@ from nba_data.models import PlayerPlayoffAdvancedData
|
|||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
||||||
|
|
||||||
teams2 = ['HOU' ,'PHI', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
|
||||||
|
|
||||||
team_abbreviations = ['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']
|
|
||||||
|
|
||||||
season = input('What season? ')
|
season = input('What season? ')
|
||||||
|
|
||||||
for team in teams:
|
teams2 = 'PHI'
|
||||||
|
|
||||||
|
for team in teams2:
|
||||||
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
||||||
response = requests.get(url_make)
|
response = requests.get(url_make)
|
||||||
|
|
||||||
|
|||||||
@@ -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']
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from bs4 import BeautifulSoup
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from data import teams_data
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
@@ -27,14 +28,11 @@ from nba_data.models import PlayerPlayoffTotalsData
|
|||||||
# Change LAC to SDC for 1984 and prior.
|
# Change LAC to SDC for 1984 and prior.
|
||||||
|
|
||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'SEA', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
||||||
|
|
||||||
|
|
||||||
team_abbreviations = ['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']
|
|
||||||
|
|
||||||
season = input('What season? ')
|
season = input('What season? ')
|
||||||
|
|
||||||
for team in teams:
|
for team in teams_data:
|
||||||
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
||||||
response = requests.get(url_make)
|
response = requests.get(url_make)
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ django.setup()
|
|||||||
|
|
||||||
from nba_data.models import PlayerShotChartData
|
from nba_data.models import PlayerShotChartData
|
||||||
|
|
||||||
player_name = 'LeBron James'
|
player_name = 'Damian Lillard'
|
||||||
season = 2014
|
season = 2013
|
||||||
# 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/' + \
|
# Player name and season will be inserted into DB. Modify before running script.
|
||||||
|
url = 'https://www.basketball-reference.com/players/l/lillada01/shooting/' + \
|
||||||
str(season)
|
str(season)
|
||||||
|
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@@ -110,4 +111,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}")
|
||||||
@@ -6,6 +6,7 @@ from bs4 import BeautifulSoup
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from data import teams_data
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
@@ -26,14 +27,14 @@ from nba_data.models import PlayerTotalsData
|
|||||||
# Change MEM to VAN for 2001 and prior.
|
# Change MEM to VAN for 2001 and prior.
|
||||||
# Change LAC to SDC for 1984 and prior.
|
# Change LAC to SDC for 1984 and prior.
|
||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'NJN', 'TOR', 'MEM', 'NOH', 'DAL', 'SAS', 'DEN', 'MIN', 'SEA', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
||||||
|
|
||||||
|
|
||||||
# team = input('What team? ')
|
# team = input('What team? ')
|
||||||
# OMIT above. Will now only ask for season and iterate thru teams list.
|
# OMIT above. Will now only ask for season and iterate thru teams list.
|
||||||
season = input('What season? ')
|
season = input('What season? ')
|
||||||
|
|
||||||
for team in teams:
|
for team in teams_data:
|
||||||
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
url_make = 'https://www.basketball-reference.com/teams/' + team + '/' + season + '.html'
|
||||||
response = requests.get(url_make)
|
response = requests.get(url_make)
|
||||||
|
|
||||||
|
|||||||
+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