Python 3 wrapper for the U.S. Energy Information Administration API.
pip install eiapy
Get the last 5 measurements of the electricity flow between California and Mexico.
>>> from eiapy import Series
>>> cal_to_mex = Series('EBA.CISO-CFE.ID.H')
>>> cal_to_mex.last(5)
{'request': {'command': 'series', 'series_id': 'EBA.CISO-CFE.ID.H'},
'series': [{'data': [['20180401T07Z', -11],
['20180401T06Z', -16],
['20180401T05Z', -11],
['20180401T04Z', -7],
['20180401T03Z', -5]],
'description': 'Timestamps follow the ISO8601 standard '
'(https://en.wikipedia.org/wiki/ISO_8601). Hourly '
'representations are provided in Universal Time.',
'end': '20180401T07Z',
'f': 'H',
'name': 'Actual Net Interchange for California Independent System '
'Operator (CISO) to Comision Federal de Electricidad '
'(CFE), Hourly',
'series_id': 'EBA.CISO-CFE.ID.H',
'start': '20150701T00Z',
'units': 'megawatthours',
'updated': '2018-04-02T08:43:16-0400'}]}
Further examples can be found in this gist.
To find more details about the API go to the EIA's Open Data page. To find interesting data (and identifiers) browse the data sets.
For specific information about the real-time grid display please see this guide.
Go here to see the API terms of service and here for an explanation of copyright and reuse of their data.
An API key is needed to access the EIA's data, you can get one here. eiapy needs this key to be manually set in the operating system environmental variables.
Mac & Linux
Open a terminal and enter the following;
export EIA_KEY=type_your_api_key_here
To set it permanently follow the instructions on this stackexchange question.
Windows
Open a Command Prompt and enter the following;
setx EIA_KEY "type_your_api_key_within_the_quotes"
{'request': {'series_id': 'eba.ciso-cfe.id.', 'command': 'series', 'num': '5'},
'data': {'error': 'invalid series_id. For key registration, documentation, and
examples see https://www.eia.gov/developer/'}}
0.1.6
0.1.5
0.1.4
repr
.0.1.3
0.1.2
0.1.1