Skip to content

api error not fetching 'Series" data from API #9

@olegvuk

Description

@olegvuk

Hi, I have been using this package fine up to now, but just recently began throwing up an error from the following code, as an

api_key = "XXX"
api = eia.API(api_key)

###Lower 48
series_search = api.data_by_series(series='NG.NW2_EPG0_SWO_R48_BCF.W')

I now get this error: ---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Input In [1], in <cell line: 28>()
24 api = eia.API(api_key)
27 ###Lower 48
---> 28 series_search = api.data_by_series(series='NG.NW2_EPG0_SWO_R48_BCF.W')
30 for key,value in series_search.items():
31 print(key,value)

File ~\anaconda3\lib\site-packages\eia\api.py:424, in API.data_by_series(self, series)
420 raise InvalidSeries(error_msg)
422 else:
423 lst_dates = [x[0][0:4] + " " + x[0][4:] + " " + x[0][6:8]
--> 424 for x in search.json()['series'][0]['data']]
425 lst_values = [x[1] for x in
426 search.json()['series'][0]['data']]
427 dates_values_dict = dict(zip(lst_dates, lst_values))

KeyError: 'series'

do you have any ideas what could be causing it or a fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions