Skip to main content

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

3. API key setup

You need a free EIA API key.

  1. Register at: https://www.eia.gov/opendata/register.php
  2. 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

eia_ng_client-0.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eia_ng_client-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file eia_ng_client-0.1.1.tar.gz.

File metadata

  • Download URL: eia_ng_client-0.1.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.12 Darwin/24.5.0

File hashes

Hashes for eia_ng_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8432c3f5a703b39b45ae2b9f9feb724419fc855545d2cc82dc2480a9141205fb
MD5 488d0b9082161517b0c9b3546708ee72
BLAKE2b-256 7e95d531d2c71ba68e521fe216404578793da15c3bcd2fae835388857333a74b

See more details on using hashes here.

File details

Details for the file eia_ng_client-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: eia_ng_client-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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

Hashes for eia_ng_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff8cc70d346b6184d2ddaeaf49f89577f40c9ef4ad865680db99f9e909af4d4d
MD5 99d202027150623c5a2c81f1eb2f9c02
BLAKE2b-256 947e4ad81654807a42d383852ef68d9c8f32301a845fe0734729c069377ada3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page