nba_api 1.7__0-py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nba_api/__init__.py +1 -0
- nba_api/library/__init__.py +0 -0
- nba_api/library/_enum_base.py +48 -0
- nba_api/library/debug/__init__.py +0 -0
- nba_api/library/debug/debug.py +8 -0
- nba_api/library/http.py +183 -0
- nba_api/live/__init__.py +1 -0
- nba_api/live/nba/__init__.py +0 -0
- nba_api/live/nba/endpoints/__init__.py +5 -0
- nba_api/live/nba/endpoints/_base.py +28 -0
- nba_api/live/nba/endpoints/boxscore.py +372 -0
- nba_api/live/nba/endpoints/playbyplay.py +90 -0
- nba_api/live/nba/endpoints/scoreboard.py +109 -0
- nba_api/live/nba/library/__init__.py +0 -0
- nba_api/live/nba/library/http.py +26 -0
- nba_api/stats/__init__.py +0 -0
- nba_api/stats/endpoints/__init__.py +271 -0
- nba_api/stats/endpoints/_base.py +87 -0
- nba_api/stats/endpoints/alltimeleadersgrids.py +94 -0
- nba_api/stats/endpoints/assistleaders.py +66 -0
- nba_api/stats/endpoints/assisttracker.py +121 -0
- nba_api/stats/endpoints/boxscoreadvancedv2.py +132 -0
- nba_api/stats/endpoints/boxscoreadvancedv3.py +139 -0
- nba_api/stats/endpoints/boxscoredefensivev2.py +82 -0
- nba_api/stats/endpoints/boxscorefourfactorsv2.py +107 -0
- nba_api/stats/endpoints/boxscorefourfactorsv3.py +110 -0
- nba_api/stats/endpoints/boxscorehustlev2.py +100 -0
- nba_api/stats/endpoints/boxscorematchupsv3.py +89 -0
- nba_api/stats/endpoints/boxscoremiscv2.py +111 -0
- nba_api/stats/endpoints/boxscoremiscv3.py +118 -0
- nba_api/stats/endpoints/boxscoreplayertrackv2.py +100 -0
- nba_api/stats/endpoints/boxscoreplayertrackv3.py +107 -0
- nba_api/stats/endpoints/boxscorescoringv2.py +117 -0
- nba_api/stats/endpoints/boxscorescoringv3.py +124 -0
- nba_api/stats/endpoints/boxscoresummaryv2.py +151 -0
- nba_api/stats/endpoints/boxscoretraditionalv2.py +155 -0
- nba_api/stats/endpoints/boxscoretraditionalv3.py +163 -0
- nba_api/stats/endpoints/boxscoreusagev2.py +123 -0
- nba_api/stats/endpoints/boxscoreusagev3.py +130 -0
- nba_api/stats/endpoints/commonallplayers.py +71 -0
- nba_api/stats/endpoints/commonplayerinfo.py +97 -0
- nba_api/stats/endpoints/commonplayoffseries.py +62 -0
- nba_api/stats/endpoints/commonteamroster.py +83 -0
- nba_api/stats/endpoints/commonteamyears.py +50 -0
- nba_api/stats/endpoints/cumestatsplayer.py +140 -0
- nba_api/stats/endpoints/cumestatsplayergames.py +76 -0
- nba_api/stats/endpoints/cumestatsteam.py +149 -0
- nba_api/stats/endpoints/cumestatsteamgames.py +78 -0
- nba_api/stats/endpoints/defensehub.py +129 -0
- nba_api/stats/endpoints/draftboard.py +85 -0
- nba_api/stats/endpoints/draftcombinedrillresults.py +64 -0
- nba_api/stats/endpoints/draftcombinenonstationaryshooting.py +82 -0
- nba_api/stats/endpoints/draftcombineplayeranthro.py +70 -0
- nba_api/stats/endpoints/draftcombinespotshooting.py +103 -0
- nba_api/stats/endpoints/draftcombinestats.py +99 -0
- nba_api/stats/endpoints/drafthistory.py +80 -0
- nba_api/stats/endpoints/fantasywidget.py +124 -0
- nba_api/stats/endpoints/franchisehistory.py +84 -0
- nba_api/stats/endpoints/franchiseleaders.py +68 -0
- nba_api/stats/endpoints/franchiseplayers.py +89 -0
- nba_api/stats/endpoints/gamerotation.py +79 -0
- nba_api/stats/endpoints/glalumboxscoresimilarityscore.py +73 -0
- nba_api/stats/endpoints/homepageleaders.py +104 -0
- nba_api/stats/endpoints/homepagev2.py +104 -0
- nba_api/stats/endpoints/hustlestatsboxscore.py +97 -0
- nba_api/stats/endpoints/infographicfanduelplayer.py +76 -0
- nba_api/stats/endpoints/iststandings.py +104 -0
- nba_api/stats/endpoints/leaderstiles.py +92 -0
- nba_api/stats/endpoints/leaguedashlineups.py +181 -0
- nba_api/stats/endpoints/leaguedashoppptshot.py +136 -0
- nba_api/stats/endpoints/leaguedashplayerbiostats.py +158 -0
- nba_api/stats/endpoints/leaguedashplayerclutch.py +222 -0
- nba_api/stats/endpoints/leaguedashplayerptshot.py +159 -0
- nba_api/stats/endpoints/leaguedashplayershotlocations.py +194 -0
- nba_api/stats/endpoints/leaguedashplayerstats.py +214 -0
- nba_api/stats/endpoints/leaguedashptdefend.py +147 -0
- nba_api/stats/endpoints/leaguedashptstats.py +146 -0
- nba_api/stats/endpoints/leaguedashptteamdefend.py +121 -0
- nba_api/stats/endpoints/leaguedashteamclutch.py +200 -0
- nba_api/stats/endpoints/leaguedashteamptshot.py +136 -0
- nba_api/stats/endpoints/leaguedashteamshotlocations.py +179 -0
- nba_api/stats/endpoints/leaguedashteamstats.py +193 -0
- nba_api/stats/endpoints/leaguegamefinder.py +269 -0
- nba_api/stats/endpoints/leaguegamelog.py +105 -0
- nba_api/stats/endpoints/leaguehustlestatsplayer.py +143 -0
- nba_api/stats/endpoints/leaguehustlestatsteam.py +135 -0
- nba_api/stats/endpoints/leagueleaders.py +99 -0
- nba_api/stats/endpoints/leaguelineupviz.py +150 -0
- nba_api/stats/endpoints/leagueplayerondetails.py +172 -0
- nba_api/stats/endpoints/leagueseasonmatchups.py +93 -0
- nba_api/stats/endpoints/leaguestandings.py +145 -0
- nba_api/stats/endpoints/leaguestandingsv3.py +179 -0
- nba_api/stats/endpoints/matchupsrollup.py +89 -0
- nba_api/stats/endpoints/playbyplay.py +71 -0
- nba_api/stats/endpoints/playbyplayv2.py +93 -0
- nba_api/stats/endpoints/playbyplayv3.py +82 -0
- nba_api/stats/endpoints/playerawards.py +59 -0
- nba_api/stats/endpoints/playercareerbycollege.py +91 -0
- nba_api/stats/endpoints/playercareerbycollegerollup.py +169 -0
- nba_api/stats/endpoints/playercareerstats.py +362 -0
- nba_api/stats/endpoints/playercompare.py +172 -0
- nba_api/stats/endpoints/playerdashboardbyclutch.py +850 -0
- nba_api/stats/endpoints/playerdashboardbygamesplits.py +448 -0
- nba_api/stats/endpoints/playerdashboardbygeneralsplits.py +580 -0
- nba_api/stats/endpoints/playerdashboardbylastngames.py +515 -0
- nba_api/stats/endpoints/playerdashboardbyshootingsplits.py +394 -0
- nba_api/stats/endpoints/playerdashboardbyteamperformance.py +387 -0
- nba_api/stats/endpoints/playerdashboardbyyearoveryear.py +253 -0
- nba_api/stats/endpoints/playerdashptpass.py +140 -0
- nba_api/stats/endpoints/playerdashptreb.py +205 -0
- nba_api/stats/endpoints/playerdashptshotdefend.py +111 -0
- nba_api/stats/endpoints/playerdashptshots.py +256 -0
- nba_api/stats/endpoints/playerestimatedmetrics.py +91 -0
- nba_api/stats/endpoints/playerfantasyprofile.py +251 -0
- nba_api/stats/endpoints/playerfantasyprofilebargraph.py +96 -0
- nba_api/stats/endpoints/playergamelog.py +90 -0
- nba_api/stats/endpoints/playergamelogs.py +172 -0
- nba_api/stats/endpoints/playergamestreakfinder.py +251 -0
- nba_api/stats/endpoints/playerindex.py +110 -0
- nba_api/stats/endpoints/playernextngames.py +79 -0
- nba_api/stats/endpoints/playerprofilev2.py +464 -0
- nba_api/stats/endpoints/playervsplayer.py +300 -0
- nba_api/stats/endpoints/playoffpicture.py +229 -0
- nba_api/stats/endpoints/scoreboardv2.py +190 -0
- nba_api/stats/endpoints/shotchartdetail.py +171 -0
- nba_api/stats/endpoints/shotchartleaguewide.py +59 -0
- nba_api/stats/endpoints/shotchartlineupdetail.py +145 -0
- nba_api/stats/endpoints/synergyplaytypes.py +95 -0
- nba_api/stats/endpoints/teamandplayersvsplayers.py +284 -0
- nba_api/stats/endpoints/teamdashboardbygeneralsplits.py +485 -0
- nba_api/stats/endpoints/teamdashboardbyshootingsplits.py +371 -0
- nba_api/stats/endpoints/teamdashlineups.py +236 -0
- nba_api/stats/endpoints/teamdashptpass.py +132 -0
- nba_api/stats/endpoints/teamdashptreb.py +203 -0
- nba_api/stats/endpoints/teamdashptshots.py +226 -0
- nba_api/stats/endpoints/teamdetails.py +84 -0
- nba_api/stats/endpoints/teamestimatedmetrics.py +89 -0
- nba_api/stats/endpoints/teamgamelog.py +90 -0
- nba_api/stats/endpoints/teamgamelogs.py +164 -0
- nba_api/stats/endpoints/teamgamestreakfinder.py +449 -0
- nba_api/stats/endpoints/teamhistoricalleaders.py +76 -0
- nba_api/stats/endpoints/teaminfocommon.py +94 -0
- nba_api/stats/endpoints/teamplayerdashboard.py +238 -0
- nba_api/stats/endpoints/teamplayeronoffdetails.py +298 -0
- nba_api/stats/endpoints/teamplayeronoffsummary.py +206 -0
- nba_api/stats/endpoints/teamvsplayer.py +399 -0
- nba_api/stats/endpoints/teamyearbyyearstats.py +93 -0
- nba_api/stats/endpoints/videodetails.py +131 -0
- nba_api/stats/endpoints/videodetailsasset.py +131 -0
- nba_api/stats/endpoints/videoevents.py +47 -0
- nba_api/stats/endpoints/videoeventsasset.py +47 -0
- nba_api/stats/endpoints/videostatus.py +66 -0
- nba_api/stats/endpoints/winprobabilitypbp.py +78 -0
- nba_api/stats/library/__init__.py +0 -0
- nba_api/stats/library/data.py +6187 -0
- nba_api/stats/library/eventmsgtype.py +20 -0
- nba_api/stats/library/http.py +163 -0
- nba_api/stats/library/parameters.py +877 -0
- nba_api/stats/library/parserv3.py +364 -0
- nba_api/stats/library/playbyplayregex.py +178 -0
- nba_api/stats/static/__init__.py +1 -0
- nba_api/stats/static/players.py +128 -0
- nba_api/stats/static/teams.py +150 -0
- nba_api-1.7.0.dist-info/LICENSE +21 -0
- nba_api-1.7.0.dist-info/METADATA +134 -0
- nba_api-1.7.0.dist-info/RECORD +167 -0
- nba_api-1.7.0.dist-info/WHEEL +4 -0
nba_api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
name = "nba_api"
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from enum import Enum, EnumMeta
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class OnAccess(EnumMeta):
|
|
5
|
+
"""
|
|
6
|
+
runs a user-specified function whenever member is accessed
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __getattribute__(cls, name):
|
|
10
|
+
obj = super().__getattribute__(name)
|
|
11
|
+
if isinstance(obj, Enum) and obj._on_access:
|
|
12
|
+
obj._on_access()
|
|
13
|
+
return obj
|
|
14
|
+
|
|
15
|
+
def __getitem__(cls, name):
|
|
16
|
+
member = super().__getitem__(name)
|
|
17
|
+
if member._on_access:
|
|
18
|
+
member._on_access()
|
|
19
|
+
return member
|
|
20
|
+
|
|
21
|
+
def __call__(
|
|
22
|
+
cls, value, names=None, *, module=None, qualname=None, type=None, start=1
|
|
23
|
+
):
|
|
24
|
+
obj = super().__call__(
|
|
25
|
+
value, names, module=module, qualname=qualname, type=type, start=start
|
|
26
|
+
)
|
|
27
|
+
if isinstance(obj, Enum) and obj._on_access:
|
|
28
|
+
obj._on_access()
|
|
29
|
+
return obj
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class DeprecatedEnum(Enum, metaclass=OnAccess):
|
|
33
|
+
def __new__(cls, value, *args):
|
|
34
|
+
member = object.__new__(cls)
|
|
35
|
+
member._value_ = value
|
|
36
|
+
member._args = args
|
|
37
|
+
member._on_access = member.deprecate if args else None
|
|
38
|
+
return member
|
|
39
|
+
|
|
40
|
+
def deprecate(self):
|
|
41
|
+
args = self._args
|
|
42
|
+
import warnings
|
|
43
|
+
|
|
44
|
+
warnings.warn(
|
|
45
|
+
"%s" % args,
|
|
46
|
+
DeprecationWarning,
|
|
47
|
+
stacklevel=3,
|
|
48
|
+
)
|
|
File without changes
|
nba_api/library/http.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import random
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
from urllib.parse import quote_plus
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from nba_api.library.debug.debug import DEBUG
|
|
10
|
+
except ImportError:
|
|
11
|
+
DEBUG = False
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
from nba_api.library.debug.debug import DEBUG_STORAGE
|
|
16
|
+
except ImportError:
|
|
17
|
+
DEBUG_STORAGE = False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
from nba_api.library.debug.debug import PROXY
|
|
22
|
+
except ImportError:
|
|
23
|
+
PROXY = ""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if DEBUG:
|
|
27
|
+
from hashlib import md5
|
|
28
|
+
|
|
29
|
+
print("DEBUG MODE")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class NBAResponse:
|
|
33
|
+
def __init__(self, response, status_code, url):
|
|
34
|
+
self._response = response
|
|
35
|
+
self._status_code = status_code
|
|
36
|
+
self._url = url
|
|
37
|
+
|
|
38
|
+
def get_response(self):
|
|
39
|
+
return self._response
|
|
40
|
+
|
|
41
|
+
def get_dict(self):
|
|
42
|
+
return json.loads(self._response)
|
|
43
|
+
|
|
44
|
+
def get_json(self):
|
|
45
|
+
return json.dumps(self.get_dict())
|
|
46
|
+
|
|
47
|
+
def valid_json(self):
|
|
48
|
+
try:
|
|
49
|
+
self.get_dict()
|
|
50
|
+
except ValueError:
|
|
51
|
+
return False
|
|
52
|
+
return True
|
|
53
|
+
|
|
54
|
+
def get_url(self):
|
|
55
|
+
return self._url
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NBAHTTP:
|
|
59
|
+
nba_response = NBAResponse
|
|
60
|
+
|
|
61
|
+
base_url = None
|
|
62
|
+
|
|
63
|
+
parameters = None
|
|
64
|
+
|
|
65
|
+
headers = None
|
|
66
|
+
|
|
67
|
+
_session = None
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def get_session(cls):
|
|
71
|
+
session = cls._session
|
|
72
|
+
if session is None:
|
|
73
|
+
session = requests.Session()
|
|
74
|
+
cls._session = session
|
|
75
|
+
return session
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def set_session(cls, session) -> None:
|
|
79
|
+
cls._session = session
|
|
80
|
+
|
|
81
|
+
def clean_contents(self, contents):
|
|
82
|
+
return contents
|
|
83
|
+
|
|
84
|
+
def send_api_request(
|
|
85
|
+
self,
|
|
86
|
+
endpoint,
|
|
87
|
+
parameters,
|
|
88
|
+
referer=None,
|
|
89
|
+
proxy=None,
|
|
90
|
+
headers=None,
|
|
91
|
+
timeout=None,
|
|
92
|
+
raise_exception_on_error=False,
|
|
93
|
+
):
|
|
94
|
+
if not self.base_url:
|
|
95
|
+
raise Exception("Cannot use send_api_request from _HTTP class.")
|
|
96
|
+
base_url = self.base_url.format(endpoint=endpoint)
|
|
97
|
+
endpoint = endpoint.lower()
|
|
98
|
+
self.parameters = parameters
|
|
99
|
+
|
|
100
|
+
if headers is None:
|
|
101
|
+
request_headers = self.headers
|
|
102
|
+
else:
|
|
103
|
+
request_headers = headers
|
|
104
|
+
|
|
105
|
+
if referer:
|
|
106
|
+
request_headers["Referer"] = referer
|
|
107
|
+
|
|
108
|
+
if proxy is None:
|
|
109
|
+
request_proxy = PROXY
|
|
110
|
+
elif not proxy:
|
|
111
|
+
request_proxy = None
|
|
112
|
+
else:
|
|
113
|
+
request_proxy = proxy
|
|
114
|
+
|
|
115
|
+
if isinstance(request_proxy, list):
|
|
116
|
+
request_proxy = random.choice(request_proxy)
|
|
117
|
+
if DEBUG:
|
|
118
|
+
print(request_proxy)
|
|
119
|
+
|
|
120
|
+
proxies = None
|
|
121
|
+
if request_proxy:
|
|
122
|
+
proxies = {
|
|
123
|
+
"http": request_proxy,
|
|
124
|
+
"https": request_proxy,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
url = None
|
|
128
|
+
status_code = None
|
|
129
|
+
contents = None
|
|
130
|
+
|
|
131
|
+
# Sort parameters by key... for some reason this matters for some requests...
|
|
132
|
+
parameters = sorted(parameters.items(), key=lambda kv: kv[0])
|
|
133
|
+
|
|
134
|
+
if DEBUG and DEBUG_STORAGE:
|
|
135
|
+
print(endpoint, parameters)
|
|
136
|
+
directory_name = "debug_storage"
|
|
137
|
+
parameter_string = "&".join(
|
|
138
|
+
"{}={}".format(key, "" if val is None else quote_plus(str(val)))
|
|
139
|
+
for key, val in parameters
|
|
140
|
+
)
|
|
141
|
+
url = "{}?{}".format(base_url, parameter_string)
|
|
142
|
+
print(url)
|
|
143
|
+
file_name = "{}-{}.txt".format(
|
|
144
|
+
endpoint, md5(parameter_string.encode("utf-8")).hexdigest()
|
|
145
|
+
)
|
|
146
|
+
file_path = os.path.join(
|
|
147
|
+
os.path.dirname(os.path.abspath(__file__)), "debug", directory_name
|
|
148
|
+
)
|
|
149
|
+
if not os.path.exists(file_path):
|
|
150
|
+
os.makedirs(file_path)
|
|
151
|
+
file_path = os.path.join(file_path, file_name)
|
|
152
|
+
print(file_name, os.path.isfile(file_path))
|
|
153
|
+
if os.path.isfile(file_path):
|
|
154
|
+
f = open(file_path, "r")
|
|
155
|
+
contents = f.read()
|
|
156
|
+
f.close()
|
|
157
|
+
print("loading from file...")
|
|
158
|
+
|
|
159
|
+
if not contents:
|
|
160
|
+
response = self.get_session().get(
|
|
161
|
+
url=base_url,
|
|
162
|
+
params=parameters,
|
|
163
|
+
headers=request_headers,
|
|
164
|
+
proxies=proxies,
|
|
165
|
+
timeout=timeout,
|
|
166
|
+
)
|
|
167
|
+
url = response.url
|
|
168
|
+
status_code = response.status_code
|
|
169
|
+
contents = response.text
|
|
170
|
+
|
|
171
|
+
contents = self.clean_contents(contents)
|
|
172
|
+
if DEBUG and DEBUG_STORAGE:
|
|
173
|
+
f = open(file_path, "w")
|
|
174
|
+
f.write(contents)
|
|
175
|
+
f.close()
|
|
176
|
+
print(url)
|
|
177
|
+
|
|
178
|
+
data = self.nba_response(response=contents, status_code=status_code, url=url)
|
|
179
|
+
|
|
180
|
+
if raise_exception_on_error and not data.valid_json():
|
|
181
|
+
raise Exception("InvalidResponse: Response is not in a valid JSON format.")
|
|
182
|
+
|
|
183
|
+
return data
|
nba_api/live/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Endpoint:
|
|
5
|
+
class DataSet:
|
|
6
|
+
key = None
|
|
7
|
+
data = {}
|
|
8
|
+
|
|
9
|
+
def __init__(self, data={}):
|
|
10
|
+
self.data = data
|
|
11
|
+
|
|
12
|
+
def get_json(self):
|
|
13
|
+
return json.dumps(self.data)
|
|
14
|
+
|
|
15
|
+
def get_dict(self):
|
|
16
|
+
return self.data
|
|
17
|
+
|
|
18
|
+
def get_request_url(self):
|
|
19
|
+
return self.nba_response.get_url()
|
|
20
|
+
|
|
21
|
+
def get_response(self):
|
|
22
|
+
return self.nba_response.get_response()
|
|
23
|
+
|
|
24
|
+
def get_dict(self):
|
|
25
|
+
return self.nba_response.get_dict()
|
|
26
|
+
|
|
27
|
+
def get_json(self):
|
|
28
|
+
return self.nba_response.get_json()
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
from nba_api.live.nba.endpoints._base import Endpoint
|
|
2
|
+
from nba_api.live.nba.library.http import NBALiveHTTP
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BoxScore(Endpoint):
|
|
6
|
+
endpoint_url = "boxscore/boxscore_{game_id}.json"
|
|
7
|
+
expected_data = {
|
|
8
|
+
"meta": {
|
|
9
|
+
"version": 1,
|
|
10
|
+
"code": 200,
|
|
11
|
+
"request": "http://nba.cloud/games/0022000180/boxscore?Format=json",
|
|
12
|
+
"time": "2021-01-15 23:51:25.282704",
|
|
13
|
+
},
|
|
14
|
+
"game": {
|
|
15
|
+
"gameId": "0022000180",
|
|
16
|
+
"gameTimeLocal": "2021-01-15T19:30:00-05:00",
|
|
17
|
+
"gameTimeUTC": "2021-01-16T00:30:00Z",
|
|
18
|
+
"gameTimeHome": "2021-01-15T19:30:00-05:00",
|
|
19
|
+
"gameTimeAway": "2021-01-15T19:30:00-05:00",
|
|
20
|
+
"gameEt": "2021-01-15T19:30:00-05:00",
|
|
21
|
+
"duration": 125,
|
|
22
|
+
"gameCode": "20210115/ORLBOS",
|
|
23
|
+
"gameStatusText": "Final",
|
|
24
|
+
"gameStatus": 3,
|
|
25
|
+
"regulationPeriods": 4,
|
|
26
|
+
"period": 4,
|
|
27
|
+
"gameClock": "PT00M00.00S",
|
|
28
|
+
"attendance": 0,
|
|
29
|
+
"sellout": "0",
|
|
30
|
+
"arena": {
|
|
31
|
+
"arenaId": 17,
|
|
32
|
+
"arenaName": "TD Garden",
|
|
33
|
+
"arenaCity": "Boston",
|
|
34
|
+
"arenaState": "MA",
|
|
35
|
+
"arenaCountry": "US",
|
|
36
|
+
"arenaTimezone": "America/New_York",
|
|
37
|
+
},
|
|
38
|
+
"officials": [
|
|
39
|
+
{
|
|
40
|
+
"personId": 201638,
|
|
41
|
+
"name": "Brent Barnaky",
|
|
42
|
+
"nameI": "B. Barnaky",
|
|
43
|
+
"firstName": "Brent",
|
|
44
|
+
"familyName": "Barnaky",
|
|
45
|
+
"jerseyNum": "36",
|
|
46
|
+
"assignment": "OFFICIAL1",
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"homeTeam": {
|
|
50
|
+
"teamId": 1610612738,
|
|
51
|
+
"teamName": "Celtics",
|
|
52
|
+
"teamCity": "Boston",
|
|
53
|
+
"teamTricode": "BOS",
|
|
54
|
+
"score": 124,
|
|
55
|
+
"inBonus": "1",
|
|
56
|
+
"timeoutsRemaining": 2,
|
|
57
|
+
"periods": [{"period": 1, "periodType": "REGULAR", "score": 34}],
|
|
58
|
+
"players": [
|
|
59
|
+
{
|
|
60
|
+
"status": "ACTIVE",
|
|
61
|
+
"order": 1,
|
|
62
|
+
"personId": 1627759,
|
|
63
|
+
"jerseyNum": "7",
|
|
64
|
+
"position": "SF",
|
|
65
|
+
"starter": "1",
|
|
66
|
+
"oncourt": "0",
|
|
67
|
+
"played": "1",
|
|
68
|
+
"statistics": {
|
|
69
|
+
"assists": 8,
|
|
70
|
+
"blocks": 0,
|
|
71
|
+
"blocksReceived": 0,
|
|
72
|
+
"fieldGoalsAttempted": 12,
|
|
73
|
+
"fieldGoalsMade": 6,
|
|
74
|
+
"fieldGoalsPercentage": 0.5,
|
|
75
|
+
"foulsOffensive": 0,
|
|
76
|
+
"foulsDrawn": 4,
|
|
77
|
+
"foulsPersonal": 1,
|
|
78
|
+
"foulsTechnical": 0,
|
|
79
|
+
"freeThrowsAttempted": 7,
|
|
80
|
+
"freeThrowsMade": 7,
|
|
81
|
+
"freeThrowsPercentage": 1.0,
|
|
82
|
+
"minus": 50.0,
|
|
83
|
+
"minutes": "PT25M01.00S",
|
|
84
|
+
"minutesCalculated": "PT25M",
|
|
85
|
+
"plus": 65.0,
|
|
86
|
+
"plusMinusPoints": 15.0,
|
|
87
|
+
"points": 21,
|
|
88
|
+
"pointsFastBreak": 0,
|
|
89
|
+
"pointsInThePaint": 6,
|
|
90
|
+
"pointsSecondChance": 0,
|
|
91
|
+
"reboundsDefensive": 2,
|
|
92
|
+
"reboundsOffensive": 0,
|
|
93
|
+
"reboundsTotal": 2,
|
|
94
|
+
"steals": 1,
|
|
95
|
+
"threePointersAttempted": 5,
|
|
96
|
+
"threePointersMade": 2,
|
|
97
|
+
"threePointersPercentage": 0.4,
|
|
98
|
+
"turnovers": 2,
|
|
99
|
+
"twoPointersAttempted": 7,
|
|
100
|
+
"twoPointersMade": 4,
|
|
101
|
+
"twoPointersPercentage": 0.5714285714285711,
|
|
102
|
+
},
|
|
103
|
+
"name": "Jaylen Brown",
|
|
104
|
+
"nameI": "J. Brown",
|
|
105
|
+
"firstName": "Jaylen",
|
|
106
|
+
"familyName": "Brown",
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"statistics": {
|
|
110
|
+
"assists": 25,
|
|
111
|
+
"assistsTurnoverRatio": 2.27272727272727,
|
|
112
|
+
"benchPoints": 66,
|
|
113
|
+
"biggestLead": 29,
|
|
114
|
+
"biggestLeadScore": "72-101",
|
|
115
|
+
"biggestScoringRun": 13,
|
|
116
|
+
"biggestScoringRunScore": "72-101",
|
|
117
|
+
"blocks": 4,
|
|
118
|
+
"blocksReceived": 1,
|
|
119
|
+
"fastBreakPointsAttempted": 9,
|
|
120
|
+
"fastBreakPointsMade": 5,
|
|
121
|
+
"fastBreakPointsPercentage": 0.555555555555556,
|
|
122
|
+
"fieldGoalsAttempted": 88,
|
|
123
|
+
"fieldGoalsEffectiveAdjusted": 0.607954545454545,
|
|
124
|
+
"fieldGoalsMade": 45,
|
|
125
|
+
"fieldGoalsPercentage": 0.511363636363636,
|
|
126
|
+
"foulsOffensive": 0,
|
|
127
|
+
"foulsDrawn": 16,
|
|
128
|
+
"foulsPersonal": 18,
|
|
129
|
+
"foulsTeam": 18,
|
|
130
|
+
"foulsTechnical": 0,
|
|
131
|
+
"foulsTeamTechnical": 0,
|
|
132
|
+
"freeThrowsAttempted": 19,
|
|
133
|
+
"freeThrowsMade": 17,
|
|
134
|
+
"freeThrowsPercentage": 0.894736842105263,
|
|
135
|
+
"leadChanges": 4,
|
|
136
|
+
"minutes": "PT240M00.00S",
|
|
137
|
+
"minutesCalculated": "PT240M",
|
|
138
|
+
"points": 124,
|
|
139
|
+
"pointsAgainst": 97,
|
|
140
|
+
"pointsFastBreak": 13,
|
|
141
|
+
"pointsFromTurnovers": 16,
|
|
142
|
+
"pointsInThePaint": 48,
|
|
143
|
+
"pointsInThePaintAttempted": 36,
|
|
144
|
+
"pointsInThePaintMade": 24,
|
|
145
|
+
"pointsInThePaintPercentage": 0.666666666666666,
|
|
146
|
+
"pointsSecondChance": 11,
|
|
147
|
+
"reboundsDefensive": 39,
|
|
148
|
+
"reboundsOffensive": 6,
|
|
149
|
+
"reboundsPersonal": 45,
|
|
150
|
+
"reboundsTeam": 6,
|
|
151
|
+
"reboundsTeamDefensive": 2,
|
|
152
|
+
"reboundsTeamOffensive": 4,
|
|
153
|
+
"reboundsTotal": 51,
|
|
154
|
+
"secondChancePointsAttempted": 6,
|
|
155
|
+
"secondChancePointsMade": 4,
|
|
156
|
+
"secondChancePointsPercentage": 0.666666666666666,
|
|
157
|
+
"steals": 7,
|
|
158
|
+
"threePointersAttempted": 42,
|
|
159
|
+
"threePointersMade": 17,
|
|
160
|
+
"threePointersPercentage": 0.40476190476190504,
|
|
161
|
+
"timeLeading": "PT47M16.00S",
|
|
162
|
+
"timesTied": 0,
|
|
163
|
+
"trueShootingAttempts": 96.36,
|
|
164
|
+
"trueShootingPercentage": 0.6434205064342051,
|
|
165
|
+
"turnovers": 10,
|
|
166
|
+
"turnoversTeam": 1,
|
|
167
|
+
"turnoversTotal": 11,
|
|
168
|
+
"twoPointersAttempted": 46,
|
|
169
|
+
"twoPointersMade": 28,
|
|
170
|
+
"twoPointersPercentage": 0.608695652173913,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
"awayTeam": {
|
|
174
|
+
"teamId": 1610612753,
|
|
175
|
+
"teamName": "Magic",
|
|
176
|
+
"teamCity": "Orlando",
|
|
177
|
+
"teamTricode": "ORL",
|
|
178
|
+
"score": 97,
|
|
179
|
+
"inBonus": "1",
|
|
180
|
+
"timeoutsRemaining": 2,
|
|
181
|
+
"periods": [{"period": 1, "periodType": "REGULAR", "score": 28}],
|
|
182
|
+
"players": [
|
|
183
|
+
{
|
|
184
|
+
"status": "ACTIVE",
|
|
185
|
+
"order": 1,
|
|
186
|
+
"personId": 203516,
|
|
187
|
+
"jerseyNum": "11",
|
|
188
|
+
"position": "SF",
|
|
189
|
+
"starter": "1",
|
|
190
|
+
"oncourt": "0",
|
|
191
|
+
"played": "1",
|
|
192
|
+
"statistics": {
|
|
193
|
+
"assists": 0,
|
|
194
|
+
"blocks": 0,
|
|
195
|
+
"blocksReceived": 0,
|
|
196
|
+
"fieldGoalsAttempted": 4,
|
|
197
|
+
"fieldGoalsMade": 1,
|
|
198
|
+
"fieldGoalsPercentage": 0.25,
|
|
199
|
+
"foulsOffensive": 0,
|
|
200
|
+
"foulsDrawn": 0,
|
|
201
|
+
"foulsPersonal": 3,
|
|
202
|
+
"foulsTechnical": 0,
|
|
203
|
+
"freeThrowsAttempted": 0,
|
|
204
|
+
"freeThrowsMade": 0,
|
|
205
|
+
"freeThrowsPercentage": 0.0,
|
|
206
|
+
"minus": 41.0,
|
|
207
|
+
"minutes": "PT14M34.00S",
|
|
208
|
+
"minutesCalculated": "PT14M",
|
|
209
|
+
"plus": 36.0,
|
|
210
|
+
"plusMinusPoints": -5.0,
|
|
211
|
+
"points": 2,
|
|
212
|
+
"pointsFastBreak": 0,
|
|
213
|
+
"pointsInThePaint": 2,
|
|
214
|
+
"pointsSecondChance": 0,
|
|
215
|
+
"reboundsDefensive": 1,
|
|
216
|
+
"reboundsOffensive": 0,
|
|
217
|
+
"reboundsTotal": 1,
|
|
218
|
+
"steals": 0,
|
|
219
|
+
"threePointersAttempted": 2,
|
|
220
|
+
"threePointersMade": 0,
|
|
221
|
+
"threePointersPercentage": 0.0,
|
|
222
|
+
"turnovers": 0,
|
|
223
|
+
"twoPointersAttempted": 2,
|
|
224
|
+
"twoPointersMade": 1,
|
|
225
|
+
"twoPointersPercentage": 0.5,
|
|
226
|
+
},
|
|
227
|
+
"name": "James Ennis III",
|
|
228
|
+
"nameI": "J. Ennis III",
|
|
229
|
+
"firstName": "James",
|
|
230
|
+
"familyName": "Ennis III",
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"statistics": {
|
|
234
|
+
"assists": 14,
|
|
235
|
+
"assistsTurnoverRatio": 1.07692307692308,
|
|
236
|
+
"benchPoints": 33,
|
|
237
|
+
"biggestLead": 1,
|
|
238
|
+
"biggestLeadScore": "4-3",
|
|
239
|
+
"biggestScoringRun": 13,
|
|
240
|
+
"biggestScoringRunScore": "72-101",
|
|
241
|
+
"blocks": 1,
|
|
242
|
+
"blocksReceived": 4,
|
|
243
|
+
"fastBreakPointsAttempted": 7,
|
|
244
|
+
"fastBreakPointsMade": 2,
|
|
245
|
+
"fastBreakPointsPercentage": 0.28571428571428603,
|
|
246
|
+
"fieldGoalsAttempted": 94,
|
|
247
|
+
"fieldGoalsEffectiveAdjusted": 0.441489361702128,
|
|
248
|
+
"fieldGoalsMade": 38,
|
|
249
|
+
"fieldGoalsPercentage": 0.404255319148936,
|
|
250
|
+
"foulsOffensive": 2,
|
|
251
|
+
"foulsDrawn": 18,
|
|
252
|
+
"foulsPersonal": 16,
|
|
253
|
+
"foulsTeam": 14,
|
|
254
|
+
"foulsTechnical": 1,
|
|
255
|
+
"foulsTeamTechnical": 0,
|
|
256
|
+
"freeThrowsAttempted": 22,
|
|
257
|
+
"freeThrowsMade": 14,
|
|
258
|
+
"freeThrowsPercentage": 0.636363636363636,
|
|
259
|
+
"leadChanges": 4,
|
|
260
|
+
"minutes": "PT240M00.00S",
|
|
261
|
+
"minutesCalculated": "PT240M",
|
|
262
|
+
"points": 97,
|
|
263
|
+
"pointsAgainst": 124,
|
|
264
|
+
"pointsFastBreak": 8,
|
|
265
|
+
"pointsFromTurnovers": 10,
|
|
266
|
+
"pointsInThePaint": 52,
|
|
267
|
+
"pointsInThePaintAttempted": 47,
|
|
268
|
+
"pointsInThePaintMade": 26,
|
|
269
|
+
"pointsInThePaintPercentage": 0.553191489361702,
|
|
270
|
+
"pointsSecondChance": 20,
|
|
271
|
+
"reboundsDefensive": 31,
|
|
272
|
+
"reboundsOffensive": 15,
|
|
273
|
+
"reboundsPersonal": 46,
|
|
274
|
+
"reboundsTeam": 12,
|
|
275
|
+
"reboundsTeamDefensive": 4,
|
|
276
|
+
"reboundsTeamOffensive": 8,
|
|
277
|
+
"reboundsTotal": 58,
|
|
278
|
+
"secondChancePointsAttempted": 16,
|
|
279
|
+
"secondChancePointsMade": 9,
|
|
280
|
+
"secondChancePointsPercentage": 0.5625,
|
|
281
|
+
"steals": 5,
|
|
282
|
+
"threePointersAttempted": 28,
|
|
283
|
+
"threePointersMade": 7,
|
|
284
|
+
"threePointersPercentage": 0.25,
|
|
285
|
+
"timeLeading": "PT00M30.00S",
|
|
286
|
+
"timesTied": 0,
|
|
287
|
+
"trueShootingAttempts": 103.68,
|
|
288
|
+
"trueShootingPercentage": 0.46778549382716,
|
|
289
|
+
"turnovers": 11,
|
|
290
|
+
"turnoversTeam": 2,
|
|
291
|
+
"turnoversTotal": 13,
|
|
292
|
+
"twoPointersAttempted": 66,
|
|
293
|
+
"twoPointersMade": 31,
|
|
294
|
+
"twoPointersPercentage": 0.46969696969696995,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
arena = None
|
|
301
|
+
away_team = None
|
|
302
|
+
away_team_player_stats = None
|
|
303
|
+
away_team_stats = None
|
|
304
|
+
data_sets = None
|
|
305
|
+
headers = None
|
|
306
|
+
home_team = None
|
|
307
|
+
home_team_player_stats = None
|
|
308
|
+
home_team_stats = None
|
|
309
|
+
game = None
|
|
310
|
+
game_details = None
|
|
311
|
+
nba_response = None
|
|
312
|
+
officials = None
|
|
313
|
+
|
|
314
|
+
def __init__(self, game_id, proxy=None, headers=None, timeout=30, get_request=True):
|
|
315
|
+
self.game_id = game_id
|
|
316
|
+
self.proxy = proxy
|
|
317
|
+
if headers is not None:
|
|
318
|
+
self.headers = headers
|
|
319
|
+
self.timeout = timeout
|
|
320
|
+
if get_request:
|
|
321
|
+
self.get_request()
|
|
322
|
+
|
|
323
|
+
def get_request(self):
|
|
324
|
+
self.nba_response = NBALiveHTTP().send_api_request(
|
|
325
|
+
endpoint=self.endpoint_url.format(game_id=self.game_id),
|
|
326
|
+
parameters={},
|
|
327
|
+
proxy=self.proxy,
|
|
328
|
+
headers=self.headers,
|
|
329
|
+
timeout=self.timeout,
|
|
330
|
+
)
|
|
331
|
+
self.load_response()
|
|
332
|
+
|
|
333
|
+
def load_response(self):
|
|
334
|
+
data_sets = self.nba_response.get_dict()
|
|
335
|
+
if "game" in data_sets:
|
|
336
|
+
self.game = Endpoint.DataSet(data=data_sets["game"])
|
|
337
|
+
self.game_details = self.game.get_dict().copy()
|
|
338
|
+
if "arena" in self.game.get_dict():
|
|
339
|
+
self.arena = Endpoint.DataSet(data=data_sets["game"]["arena"])
|
|
340
|
+
self.game_details.pop("arena")
|
|
341
|
+
if "officials" in self.game.get_dict():
|
|
342
|
+
self.officials = Endpoint.DataSet(data=data_sets["game"]["officials"])
|
|
343
|
+
self.game_details.pop("officials")
|
|
344
|
+
if "homeTeam" in self.game.get_dict():
|
|
345
|
+
self.home_team = Endpoint.DataSet(data=data_sets["game"]["homeTeam"])
|
|
346
|
+
|
|
347
|
+
# Home Team Player Stats
|
|
348
|
+
self.home_team_player_stats = Endpoint.DataSet(
|
|
349
|
+
data=data_sets["game"]["homeTeam"]["players"]
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
# Home Team Stats
|
|
353
|
+
home_team_stats = self.home_team.get_dict().copy()
|
|
354
|
+
home_team_stats.pop("players")
|
|
355
|
+
self.home_team_stats = Endpoint.DataSet(data=home_team_stats)
|
|
356
|
+
|
|
357
|
+
self.game_details.pop("homeTeam")
|
|
358
|
+
if "awayTeam" in self.game.get_dict():
|
|
359
|
+
self.away_team = Endpoint.DataSet(data=data_sets["game"]["awayTeam"])
|
|
360
|
+
|
|
361
|
+
# Away Team Player Stats
|
|
362
|
+
self.away_team_player_stats = Endpoint.DataSet(
|
|
363
|
+
data=data_sets["game"]["awayTeam"]["players"]
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
# Away Team Stats
|
|
367
|
+
away_team_stats = self.away_team.get_dict().copy()
|
|
368
|
+
away_team_stats.pop("players")
|
|
369
|
+
self.away_team_stats = Endpoint.DataSet(data=away_team_stats)
|
|
370
|
+
|
|
371
|
+
self.game_details.pop("awayTeam")
|
|
372
|
+
self.game_details = Endpoint.DataSet(data=self.game_details)
|