nba_api
nba_api copied to clipboard
Struggling to get BoxScore data
Is anyone else having issues getting box score data?
I've tried every endpoint and each one is failing
I am also having an issue getting the Advanced box score data, below is the error message I am receiving: ` box_adv = boxscoreadvancedv2.BoxScoreAdvancedV2(game_id = 21801211)
JSONDecodeError Traceback (most recent call last) ~/Desktop/Capstone2/more_data.py in ----> 35 box_adv = boxscoreadvancedv2.BoxScoreAdvancedV2(game_id = 21801211)
~/anaconda3/lib/python3.7/site-packages/nba_api/stats/endpoints/boxscoreadvancedv2.py in init(self, game_id, end_period, end_range, range_type, start_period, start_range, proxy, headers, timeout, get_request) 38 } 39 if get_request: ---> 40 self.get_request() 41 42 def get_request(self):
~/anaconda3/lib/python3.7/site-packages/nba_api/stats/endpoints/boxscoreadvancedv2.py in get_request(self) 48 timeout=self.timeout, 49 ) ---> 50 self.load_response() 51 52 def load_response(self):
~/anaconda3/lib/python3.7/site-packages/nba_api/stats/endpoints/boxscoreadvancedv2.py in load_response(self) 51 52 def load_response(self): ---> 53 data_sets = self.nba_response.get_data_sets() 54 self.data_sets = [Endpoint.DataSet(data=data_set) for data_set_name, data_set in data_sets.items()] 55 self.player_stats = Endpoint.DataSet(data=data_sets['PlayerStats'])
~/anaconda3/lib/python3.7/site-packages/nba_api/stats/library/http.py in get_data_sets(self) 81 82 def get_data_sets(self): ---> 83 raw_dict = self.get_dict() 84 if 'resultSets' in raw_dict: 85 results = raw_dict['resultSets']
~/anaconda3/lib/python3.7/site-packages/nba_api/library/http.py in get_dict(self) 39 40 def get_dict(self): ---> 41 return json.loads(self._response) 42 43 def get_json(self):
~/anaconda3/lib/python3.7/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 346 parse_int is None and parse_float is None and 347 parse_constant is None and object_pairs_hook is None and not kw): --> 348 return _default_decoder.decode(s) 349 if cls is None: 350 cls = JSONDecoder
~/anaconda3/lib/python3.7/json/decoder.py in decode(self, s, _w) 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end() 339 if end != len(s):
~/anaconda3/lib/python3.7/json/decoder.py in raw_decode(self, s, idx) 353 obj, end = self.scan_once(s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
Hey Justin, yeah I'm getting the same error. Do you get that for other box score endpoints?
Hey Robert, Yes, I received the same error message for every boxscore endpoint except for boxscoresimilarityscore, which I just was not able to import. If you are just looking to get basic team game stats, I worked around it and used leaguegamefinder. I'd be happy to share that code with you if that's all you need. I was hoping to get more of the advanced stats though, so I haven't found a work around for that other than just getting my hands dirty scraping. NBA-Reference is actually very scrapable, so might be another option for you to look into as well.
Oh ok, great. Just need confirmation that I wasn't being an idiot as per usual :) Thanks man!
I'll check out leaguegamefinder when I fiddle with the API this weekend. If I have difficulty I'll reply back and ask to see the code you've got :0 Thanks again for the help!
I got some of the boxscore code working:
boxscore = BoxScoreAdvancedV2(game_id='0022000513').player_stats.get_data_frame()