https://github.com/philsv/myeia
Python wrapper for the U.S. Energy Information Administration (EIA) API v2
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.1%) to scientific vocabulary
Keywords
Repository
Python wrapper for the U.S. Energy Information Administration (EIA) API v2
Basic Info
- Host: GitHub
- Owner: philsv
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://pypi.org/project/myeia/
- Size: 352 KB
Statistics
- Stars: 19
- Watchers: 1
- Forks: 7
- Open Issues: 0
- Releases: 25
Topics
Metadata Files
README.md
myeia
myeia is a simple Python wrapper for the U.S. Energy Information Administration (EIA) APIv2. It is designed to be simple to use and to provide a consistent interface for accessing EIA data.
Installation
ini
pip install myeia
Requirements
- backoff
- pandas
- python-dateutil
- python-dotenv
- requests
eia OPEN DATA Registration
To obtain an API Key you need to register on the EIA website.
eia API Query Browser
To find all EIA Datasets visit API Dashboard.
How to use
```python from myeia import API
eia = API() ```
Environment Variables
```bash
Create a .env file in your projects root directory
touch .env ```
By default the API class will look for your EIA_TOKEN.
If you have registered for an API key you can set it in your .env file.
ini
EIA_TOKEN=YOUR_TOKEN_HERE
Get Series
Lets look at an example of how to get the EIA Natural Gas Futures.
You can use the simpler v1 API method where you only need to pass the series_id or you can use the newer v2 API method where you need to pass the route, series, and frequency.
```python df = eia.getseries(seriesid="NG.RNGC1.D")
df = eia.getseriesvia_route( route="natural-gas/pri/fut", series="RNGC1", frequency="daily", )
df.head() ```
Output Example:
ini
Natural Gas Futures Contract 1 (Dollars per Million Btu)
Date
2022-09-13 8.284
2022-09-12 8.249
2022-09-09 7.996
2022-09-08 7.915
2022-09-07 7.842
... ...
Different Facets
Lets look at another example the Total OPEC Petroleum Supply where the facet is available as seriesId. By Default it is set as series but we can define the facet as seriesId.
```python df = eia.getseries(seriesid="STEO.PAPR_OPEC.M")
df = eia.getseriesviaroute( route="steo", series="PAPROPEC", frequency="monthly", facet="seriesId", )
df.head() ```
Output Example:
ini
Total OPEC Petroleum Supply
Date
2023-12-01 34.517314
2023-11-01 34.440397
2023-10-01 34.376971
2023-09-01 34.416242
2023-08-01 34.451823
... ...
Filter by multiple facets
You can also filter by multiple facets. Lets look at the UAE Crude oil, NGPL, and other liquids where the facets we choose are countryRegionId and productId.
The difference here is that both facet columns are present in the dataframe, unlike the previous examples where only one facet was present.
```python df = eia.getseriesvia_route( route="international", series=["ARE", 55], frequency="monthly", facet=["countryRegionId", "productId"], )
df.head() ```
Output Example:
ini
countryRegionId productId Crude oil, NGPL, and other liquids
Date
2024-03-01 ARE 55 4132.394334
2024-02-01 ARE 55 4132.394334
2024-01-01 ARE 55 4142.394334
2023-12-01 ARE 55 4082.394334
2023-11-01 ARE 55 4082.394334
... ... ... ...
Get Multiple Series
For multiple series you have to loop through the series and append the data to a list.
```python data = [] for item in ["RNGC1", "RNGC2"]: df = eia.getseriesvia_route( route="natural-gas/pri/fut", series=item, frequency="daily", facet="series", ) data.append(df)
df = pd.concat(data, axis=1) df.head() ```
Output Example:
ini
Natural Gas Futures Contract 1 (Dollars per Million Btu) Natural Gas Futures Contract 2 (Dollars per Million Btu)
Date
2023-08-29 2.556 2.662
2023-08-28 2.579 2.665
2023-08-25 2.540 2.657
2023-08-24 2.519 2.636
2023-08-23 2.497 2.592
... ... ...
Define a Start and End Date
You can define a start and end date for your query.
```python df = eia.getseries( seriesid="NG.RNGC1.D", startdate="2021-01-01", enddate="2021-01-31", )
df.head() ```
Output Example:
ini
Natural Gas Futures Contract 1 (Dollars per Million Btu)
Date
2021-01-29 2.564
2021-01-28 2.664
2021-01-27 2.760
2021-01-26 2.656
2021-01-25 2.602
... ...
This also works for the get_series_via_route method.
```python df = eia.getseriesviaroute( route="natural-gas/pri/fut", series="RNGC1", frequency="daily", startdate="2021-01-01", end_date="2021-01-31", )
df.head() ```
Output Example:
ini
Natural Gas Futures Contract 1 (Dollars per Million Btu)
Date
2021-01-29 2.564
2021-01-28 2.664
2021-01-27 2.760
2021-01-26 2.656
2021-01-25 2.602
... ...
Contributing
We love your input! We want to make contributing to this project as easy and transparent as possible. Read our CONTRIBUTING.md to get started.
Owner
- Name: philsv
- Login: philsv
- Kind: user
- Location: Earth
- Repositories: 2
- Profile: https://github.com/philsv
GitHub Events
Total
- Create event: 1
- Issues event: 6
- Release event: 1
- Watch event: 4
- Delete event: 1
- Issue comment event: 3
- Push event: 9
- Pull request event: 5
- Fork event: 1
Last Year
- Create event: 1
- Issues event: 6
- Release event: 1
- Watch event: 4
- Delete event: 1
- Issue comment event: 3
- Push event: 9
- Pull request event: 5
- Fork event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| philsv | 3****v | 114 |
| Carl-Christian Sautter | c****r@n****e | 11 |
| snyk-bot | s****t@s****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 15
- Total pull requests: 10
- Average time to close issues: 11 days
- Average time to close pull requests: 1 day
- Total issue authors: 10
- Total pull request authors: 6
- Average comments per issue: 3.67
- Average comments per pull request: 0.5
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 6
- Average time to close issues: 8 days
- Average time to close pull requests: 2 days
- Issue authors: 3
- Pull request authors: 2
- Average comments per issue: 2.0
- Average comments per pull request: 0.83
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- MikeMike13 (4)
- romanme2 (3)
- EPRINC-MP (2)
- ssnyu (1)
- ariasmiguel (1)
- aladakepri (1)
- rbonallo (1)
- Cyberjoe (1)
- Stevearama (1)
- csautter (1)
- Justin-Diamond (1)
Pull Request Authors
- ariasmiguel (4)
- csautter (3)
- philsv (2)
- snyk-bot (1)
- coe7841 (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 684 last-month
- Total dependent packages: 1
- Total dependent repositories: 1
- Total versions: 27
- Total maintainers: 1
pypi.org: myeia
Python Wrapper for the U.S. Energy Information Administration (EIA) APIv2.
- Homepage: https://github.com/philsv/myeia
- Documentation: https://myeia.readthedocs.io/
- License: MIT
-
Latest release: 0.4.8
published 9 months ago
Rankings
Maintainers (1)
Dependencies
- pandas >=1.3.5
- python-dotenv >=0.19.0
- requests >=2.26.0
- pandas *
- actions/checkout v2 composite
- actions/setup-python v2 composite
- pre-commit/action v2.0.0 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite