A Python client for the EIA v2 natural gas API with structured access to production, storage, flows, prices, and gas-fired electricity generation.
Project description
eia-ng
A Python client for the EIA v2 natural gas API with structured access to production, storage, consumption, imports, exports, prices, and natural-gas-fired electricity generation.
EIA API Documentation
This library is built on top of the official U.S. Energy Information Administration (EIA) Open Data API.
For detailed information about datasets, endpoints, parameters, and data definitions, refer to the official EIA API documentation:
https://www.eia.gov/opendata/documentation.php
Installation
pip install eia-ng-client
3. API key setup
You need a free EIA API key.
- Register at: https://www.eia.gov/opendata/register.php
- Set the key as an environment variable:
export EIA_API_KEY="your_api_key_here"
4. Quick start
from eia_ng import EIAClient
client = EIAClient()
# U.S. natural gas production (monthly)
production = client.natural_gas.production(start="2020-01")
print(production[:3])
# Lower 48 natural gas storage (weekly)
storage = client.natural_gas.storage(start="2022-01-01")
print(storage[:3])
# Henry Hub spot prices (daily)
prices = client.natural_gas.spot_prices(start="2023-01-01")
print(prices[:3])
5. Natural gas API overview
Natural Gas Data
The natural_gas source provides access to:
- Production (U.S. total and by state)
- Consumption (U.S. total and by state)
- Storage (by region)
- Imports (pipeline, LNG, compressed)
- Exports (pipeline, LNG, truck, compressed)
- Spot prices (Henry Hub)
- Futures prices (front-month and deferred contracts)
Production by State
# Texas natural gas production
tx_prod = client.natural_gas.production(
start="2020-01",
state="tx",
)
Storage by region
# Lower 48 storage
storage = client.natural_gas.storage(
start="2022-01-01",
region="lower48",
)
Imports / exports
# Pipeline imports from Canada
imports = client.natural_gas.imports(
start="2021-01",
country="canada_pipeline",
)
# Pipeline exports to Mexico
exports = client.natural_gas.exports(
start="2021-01",
country="mexico_pipeline",
)
Futures prices
# Front-month natural gas futures
futures = client.natural_gas.futures_prices(
start="2023-01-01",
contract=1,
)
7. Electricity generation (Natural Gas)
# U.S. electricity generation from natural gas
gen_us = client.electricity.generation_natural_gas(
start="2020-01",
)
# Utah electricity generation from natural gas
gen_ut = client.electricity.generation_natural_gas(
start="2020-01",
state="UT",
)
Returned Data Format
All methods return a list of dictionaries corresponding to rows returned by the EIA API.
You can easily convert the results to pandas using this approach.
import pandas as pd
df = pd.DataFrame(production)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eia_ng_client-0.1.3.tar.gz.
File metadata
- Download URL: eia_ng_client-0.1.3.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.12 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23fb2da6f8efd817eb08215a6c34db7b25236d080a35ce6fa7e301ae894d1772
|
|
| MD5 |
47cf66dddbb285c0ce0f17a70c299346
|
|
| BLAKE2b-256 |
8d8f5dda2bb8a9249b20ad29448fa3316068bcbfca2753ab5460192b18b3c16a
|
File details
Details for the file eia_ng_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: eia_ng_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.12 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32960836db9d39a62b3a3e0ebee4a05205852070468420797fbc6eb177b16c2f
|
|
| MD5 |
de9b0640e379d5e528495d28cfec623e
|
|
| BLAKE2b-256 |
e28b3524efb4ee2d0048e97e783bd051b8e22b6ad899f76100c370f88dfd270f
|