Skip to main content

eiapy

PyPI PyPI - License PyPI - Python Version

Python 3 wrapper for the U.S. Energy Information Administration API.

Quick start

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.

Setting up your API key

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"

Notes on API behaviour

  • When providing invalid time limits for a series data request an empty data list is returned.
  • For data requests num & start cannot be used together but num & end can.
  • When an invalid series id is passed this is the response.
{'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/'}}
  • The API expects timestamps in ISO 8601 format (YYYYMMDDTHHZ) with Z meaning UTC, bad timestamps will not raise errors.

Changelog

0.1.6

  • Changed URLs to https as http is no longer supported by EIA.
  • Added python 3.9 and 3.10 to classifiers, removed 3.5.

0.1.5

  • Added Python 3.8 to supported versions.
  • Updated readme with advice about bad timestamps.
  • Disabled broken Relation class.
  • Made handling of no api key more human friendly.

0.1.4

  • Fixed broken Search repr.
  • Added Python 3.7 to supported versions.
  • Mention real-time grid in readme.

0.1.3

  • Simplify construction and use of the Search class.
  • Explain how to set up the API key.
  • Added gist of examples to readme.

0.1.2

  • Rename several methods for extra clarity.
  • data -> get_data
  • get -> get_updates

0.1.1

  • Started using requests session functionality to improve performance.
  • Fixed a mistake in the MultiSeries class that stopped it working entirely.
  • Added a version attribute to the package.
  • Overhaul of readme.

Metadata

Release files for eiapy 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eiapy 0.1.6
File Size Uploaded Provenance Actions
eiapy-0.1.6.tar.gz 6.9 kB Without provenance Details for eiapy-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for eiapy 0.1.6
File Interpreter ABI Platform Actions
eiapy-0.1.6-py2.py3-none-any.whl Python 2, Python 3 none any Details for eiapy-0.1.6-py2.py3-none-any.whl

Total release size: 13.7 kB

Release files / eiapy-0.1.6.tar.gz

Download URL eiapy-0.1.6.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
78d17600dd4a9ae6fe6d4a720ba34b6259f1f5e46e7bea3287d089cbbe694335
BLAKE2b-256 checksum
How to use checksums
0fac8685ae153856c332db874f888d1aa32fc3de7a9ebaf73f0b47ac56e27fc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

Release files / eiapy-0.1.6-py2.py3-none-any.whl

Download URL eiapy-0.1.6-py2.py3-none-any.whl
Size 6.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b91a3c7ecc69b9da3373ae6f0c83fc2e04de11a8291d8210c2ac9666b636147e
BLAKE2b-256 checksum
How to use checksums
5d8e34e3ea2a05a4a41a88b6e3b7542e0ec701d2a9252453c9fb8037f5ee181d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

Security for eiapy 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page