pyEIA
An Energy Information Administration (EIA) API python client for researchers who just need data.
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.5%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
An Energy Information Administration (EIA) API python client for researchers who just need data.
Basic Info
Statistics
- Stars: 29
- Watchers: 3
- Forks: 6
- Open Issues: 5
- Releases: 0
Topics
Metadata Files
README.md
Configuration
You can configure pyeia with your API key either at runtime.
- Declare
EIA_APIKEY="myapikey"in a.envfile - Set an environment variable explicitly,
export EIA_APIKEY="myapikey" - If you are using dynaconf, you can include an
[eia]environment in yoursettings.tomlfile (or any other configured settings files.)
toml
[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. :
bash
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.
```python 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.CNSMDEUTOTDNADEUNAENCQBTU.A", "AEO.2015.REF2015.CNSMENUALLSNADFODELVENCQBTU.A", apikey=myapikey, ) series.todict() # 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", apikey=myapikey) geoset.todict() geoset.query_df()
Make a call to the SeriesCategory endpoint
seriescategory = api.SeriesCategory( "AEO.2015.REF2015.CNSMDEUTOTDNADEUNAENCQBTU.A", "AEO.2015.REF2015.CNSMENUALLSNADFODELVENCQBTU.A", apikey=myapikey, ) seriescategory.todict()
Make a call to the Updates endpoint
updates = api.Updates( categoryid=2102358, rows=0, firstrow="currentlynotused", deep=False, apikey=myapikey, ) updates.to_dict()
Make a call to the Search endpoint
search = api.Search(api_key=myapikey)
Make a series_id search
search.todict("seriesid", "EMICO2COMMNACLNANA_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.todict("lastupdated", ["Dec. 1st, 2014", "06/14/2015 3:45PM"]) ```
Owner
- Name: Thomas Tu
- Login: thomastu
- Kind: user
- Location: Berkeley, CA
- Website: thomastu.io
- Repositories: 34
- Profile: https://github.com/thomastu
Software/data engineer working in energy efficiency.
GitHub Events
Total
- Watch event: 4
Last Year
- Watch event: 4
Committers
Last synced: 6 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Thomas Tu | t****u@g****m | 30 |
| Thomas Tu | t****u@l****v | 25 |
| dependabot[bot] | 4****] | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- 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 requests: 5
- Bot issues: 0
- Bot pull requests: 5
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- thomastu (14)
- MattEwen (1)
- lydonjj (1)
Pull Request Authors
- dependabot[bot] (5)
- thomastu (3)
- gitter-badger (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 18 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/
- License: BSD-3-Clause-LBNL
-
Latest release: 0.1.6
published about 4 years ago
Rankings
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