systemcatch / eiapy

A simple wrapper for the U.S. Energy Information Administration API
https://pypi.org/project/eiapy/
MIT License
23 stars 8 forks source link

JSONDecodeError: Expecting value: line 1 column 1 (char 0) #28

Open bjacksonKOps opened 1 year ago

bjacksonKOps commented 1 year ago

Getting the following error when running any eiapy function (Series, Category).

JSONDecodeError Traceback (most recent call last)

in ----> 1 gulf_category = Category(296728).get_info() 2 3 # Find all child series and make a list of them. 4 gulf_childseries = gulf_category['category']['childseries'] 5 gulf_series_ids = [i['series_id'] for i in gulf_childseries] /databricks/python/lib/python3.8/site-packages/eiapy.py in get_info(self) 271 url = 'https://api.eia.gov/category/?api_key={}'.format(API_KEY) 272 --> 273 data = self._fetch(url) 274 return data 275 /databricks/python/lib/python3.8/site-packages/eiapy.py in _fetch(self, url) 262 else: 263 req = s.get(url) --> 264 json_data = req.json() 265 return json_data 266 /databricks/python/lib/python3.8/site-packages/requests/models.py in json(self, **kwargs) 898 # used. 899 pass --> 900 return complexjson.loads(self.text, **kwargs) 901 902 @property /databricks/python/lib/python3.8/site-packages/simplejson/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw) 523 parse_constant is None and object_pairs_hook is None 524 and not use_decimal and not kw): --> 525 return _default_decoder.decode(s) 526 if cls is None: 527 cls = JSONDecoder /databricks/python/lib/python3.8/site-packages/simplejson/decoder.py in decode(self, s, _w, _PY3) 368 if _PY3 and isinstance(s, bytes): 369 s = str(s, self.encoding) --> 370 obj, end = self.raw_decode(s) 371 end = _w(s, end).end() 372 if end != len(s): /databricks/python/lib/python3.8/site-packages/simplejson/decoder.py in raw_decode(self, s, idx, _w, _PY3) 398 elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf': 399 idx += 3 --> 400 return self.scan_once(s, idx=_w(s, idx).end()) JSONDecodeError: Expecting value: line 1 column 1 (char 0)
FelixDQ commented 1 year ago

We are seeing the same problem. Looks like the API is returning a 404 error:

image

Interestingly is that it works sometimes. When I keep retrying, the API sometimes returns the correct response. They haven't reported any outages as far as I can see. I think the only action item we have would be looking into their v2 API (https://github.com/systemcatch/eiapy/issues/26) or maybe contacting EIA.