https://github.com/philsv/myeia

Python wrapper for the U.S. Energy Information Administration (EIA) API v2

https://github.com/philsv/myeia

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

eia eia-api energy python statistics
Last synced: 6 months ago · JSON representation

Repository

Python wrapper for the U.S. Energy Information Administration (EIA) API v2

Basic Info
Statistics
  • Stars: 19
  • Watchers: 1
  • Forks: 7
  • Open Issues: 0
  • Releases: 25
Topics
eia eia-api energy python statistics
Created almost 4 years ago · Last pushed 9 months ago
Metadata Files
Readme Contributing License

README.md

myeia

PyPI version License: MIT Weekly Downloads Monthly Downloads Downloads

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

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

All Time
  • Total Commits: 126
  • Total Committers: 3
  • Avg Commits per committer: 42.0
  • Development Distribution Score (DDS): 0.095
Past Year
  • Commits: 28
  • Committers: 3
  • Avg Commits per committer: 9.333
  • Development Distribution Score (DDS): 0.429
Top Committers
Name Email 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.

  • Versions: 27
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 684 Last month
Rankings
Dependent packages count: 7.3%
Downloads: 14.3%
Average: 17.2%
Stargazers count: 19.4%
Dependent repos count: 22.1%
Forks count: 22.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • pandas >=1.3.5
  • python-dotenv >=0.19.0
  • requests >=2.26.0
setup.py pypi
  • pandas *
.github/workflows/pre-commit.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pre-commit/action v2.0.0 composite
.github/workflows/publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi