pyEIA
An Energy Information Administration API Python client for researchers who need data.
https://github.com/thomastu/pyEIA
Category: Energy Systems
Sub Category: Energy Data Accessibility and Integration
Keywords
eia eia-api energy energy-data python
Keywords from Contributors
archiving transforms measur generic optimize observation compose conversion projection animals
Last synced: about 21 hours ago
JSON representation
Repository metadata
An Energy Information Administration (EIA) API python client for researchers who just need data.
- Host: GitHub
- URL: https://github.com/thomastu/pyEIA
- Owner: thomastu
- Created: 2015-05-11T01:43:04.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2022-12-08T12:17:48.000Z (over 2 years ago)
- Last Synced: 2025-04-17T21:20:59.213Z (10 days ago)
- Topics: eia, eia-api, energy, energy-data, python
- Language: Python
- Homepage:
- Size: 154 KB
- Stars: 29
- Watchers: 3
- Forks: 6
- Open Issues: 5
- Releases: 0
-
Metadata Files:
- Readme: README.md
README.md
Configuration
You can configure pyeia with your API key either at runtime.
- Declare
EIA_APIKEY="myapikey"
in a.env
file - Set an environment variable explicitly,
export EIA_APIKEY="myapikey"
- If you are using dynaconf, you can include an
[eia]
environment in yoursettings.toml
file (or any other configured settings files.)
[eia]
apikey = "my apikey"
About
The U.S. Energy Information Adminsitration provides an API for access to commonly used datasets for policy makers
and researchers. See the EIA API documentation for more information.
Warning : This package is a work in progress! A substantial update is expected in January 2020, with a published version on PyPi. The author took a break from this domain area, but is returning! Hoping to have a similar or identical R interface/API as well, but that may be much farther down the pipeline.
Basic Usage
Since this package is still under active development, it has not been pushed to PyPi. That said, I believe it is
stable and reliable enough for immediate use. You can install this via git+https, i.e. :
pip install pyeia
pip show pyeia
There are two main strategies for interacting with this package.
EIA Browser
EIA provides a web-based data browser
Since most interactions for discovering data via the API will likely occur
through this browser, this motivated a programmatic version.
The general strategy is to traverse a datapath or multiple datapaths, and
when you arrive to the desired node, you flag one or more dataseries.
There is also the ability to add in meta information as you flag a dataseries.
Running the export
method on a Browser object will make a request to the
Series
API to collect data you've flagged.
There's currently a separate class for each dataset which is mostly syntactic.
In the future, there will likely be methods and visualizations builtin that are
specific to the datasets described at the root category level from EIA.
Direct API usage
Each endpoint has a corresponding class in eia.api
. Every class has a query
method that makes a call to EIA.
The returned result is always the response body. Metadata about the request is dropped. The Series
and Geoset
classes have a special query_df
method since their response bodies have a naturally tabular schema.
from eia import api
myapikey = "" # Register here : www.eia.gov/opendata/register.cfm
# Make a call to the Category endpoint
category = api.Category(myapikey)
category.query()
# Make a call to the Series endpoint
series = api.Series(
"AEO.2015.REF2015.CNSM_DEU_TOTD_NA_DEU_NA_ENC_QBTU.A",
"AEO.2015.REF2015.CNSM_ENU_ALLS_NA_DFO_DELV_ENC_QBTU.A",
api_key=myapikey,
)
series.to_dict() # Export data from its json response
# Make the same query, but get results as a pandas DataFrame
series.to_dataframe()
# Make a call to the Geoset endpoint
geoset = api.Geoset("ELEC.GEN.ALL-99.A", "USA-CA", "USA-FL", "USA-MN", api_key=myapikey)
geoset.to_dict()
geoset.query_df()
# Make a call to the SeriesCategory endpoint
seriescategory = api.SeriesCategory(
"AEO.2015.REF2015.CNSM_DEU_TOTD_NA_DEU_NA_ENC_QBTU.A",
"AEO.2015.REF2015.CNSM_ENU_ALLS_NA_DFO_DELV_ENC_QBTU.A",
api_key=myapikey,
)
seriescategory.to_dict()
# Make a call to the Updates endpoint
updates = api.Updates(
category_id=2102358,
rows=0,
firstrow="currently_not_used",
deep=False,
api_key=myapikey,
)
updates.to_dict()
# Make a call to the Search endpoint
search = api.Search(api_key=myapikey)
# Make a series_id search
search.to_dict("series_id", "EMI_CO2_COMM_NA_CL_NA_NA_MILLMETNCO2.A", "all")
# Make a name search
search.to_dict("name", "crude oil", 25)
# Make a date-range search
# Dates can be input as a list/tuple of any valid pd.to_datetime argument
search.to_dict("last_updated", ["Dec. 1st, 2014", "06/14/2015 3:45PM"])
Owner metadata
- Name: Thomas Tu
- Login: thomastu
- Email:
- Kind: user
- Description: Software/data engineer working in energy efficiency.
- Website: thomastu.io
- Location: Berkeley, CA
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/11164430?u=d8069fc8baed3d7874baa9bebe6f9e3fdeff3d17&v=4
- Repositories: 34
- Last ynced at: 2024-06-11T15:44:09.759Z
- Profile URL: https://github.com/thomastu
GitHub Events
Total
- Watch event: 4
Last Year
- Watch event: 4
Committers metadata
Last synced: 5 days ago
Total Commits: 57
Total Committers: 3
Avg Commits per committer: 19.0
Development Distribution Score (DDS): 0.474
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
Thomas Tu | t****u@g****m | 30 |
Thomas Tu | t****u@l****v | 25 |
dependabot[bot] | 4****] | 2 |
Committer domains:
- lbl.gov: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 16
Total pull requests: 9
Average time to close issues: 10 months
Average time to close pull requests: about 2 months
Total issue authors: 3
Total pull request authors: 3
Average comments per issue: 1.06
Average comments per pull request: 0.0
Merged pull request: 5
Bot issues: 0
Bot pull requests: 5
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- thomastu (14)
- MattEwen (1)
- lydonjj (1)
Top Pull Request Authors
- dependabot[bot] (5)
- thomastu (3)
- gitter-badger (1)
Top Issue Labels
Top Pull Request Labels
- dependencies (5)
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 211 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 6
- Total maintainers: 1
pypi.org: pyeia
Python client for the Energy Information Administration (EIA) API
- Homepage: https://github.com/thomastu/pyEIA
- Documentation: https://pyeia.readthedocs.io/
- Licenses: BSD-3-Clause-LBNL
- Latest release: 0.1.6 (published about 3 years ago)
- Last Synced: 2025-04-25T12:01:05.317Z (2 days ago)
- Versions: 6
- Dependent Packages: 0
- Dependent Repositories: 1
- Downloads: 211 Last month
-
Rankings:
- Dependent packages count: 7.373%
- Stargazers count: 12.203%
- Forks count: 14.287%
- Average: 19.98%
- Dependent repos count: 22.233%
- Downloads: 43.804%
- Maintainers (1)
Dependencies
- appdirs 1.4.4 develop
- atomicwrites 1.4.0 develop
- attrs 20.2.0 develop
- black 19.10b0 develop
- iniconfig 1.1.1 develop
- packaging 20.4 develop
- pathspec 0.8.0 develop
- pluggy 0.13.1 develop
- py 1.10.0 develop
- pyparsing 2.4.7 develop
- pytest 6.1.2 develop
- regex 2020.10.28 develop
- toml 0.10.2 develop
- typed-ast 1.4.1 develop
- certifi 2020.6.20
- chardet 3.0.4
- click 7.1.2
- colorama 0.4.4
- dynaconf 3.1.2
- h11 0.9.0
- h2 3.2.0
- hpack 3.0.0
- hstspreload 2020.10.20
- httpcore 0.9.1
- httpx 0.13.3
- hyperframe 5.2.0
- idna 2.10
- loguru 0.5.3
- numpy 1.21.0
- pandas 1.1.4
- python-dateutil 2.8.1
- pytz 2020.4
- rfc3986 1.4.0
- six 1.15.0
- sniffio 1.2.0
- win32-setctime 1.0.3
- black ^19.10b0 develop
- pytest ^6.0.1 develop
- click ^7.1.2
- dynaconf ^3.0.0
- httpx ^0.13.3
- loguru ^0.5.1
- pandas ^1.1.0
- python ^3.8
- actions/checkout v2 composite
- github/codeql-action/analyze v1 composite
- github/codeql-action/autobuild v1 composite
- github/codeql-action/init v1 composite
Score: 9.986264978993697