# EIA Energy Data Normalizer (`wakey7dev/eia-energy-normalizer`) Actor

Fetch and normalize US energy data from the EIA API v2. Petroleum, natural gas, electricity, coal, renewables. Free API key.

- **URL**: https://apify.com/wakey7dev/eia-energy-normalizer.md
- **Developed by:** [Chris Wakefield](https://apify.com/wakey7dev) (community)
- **Categories:** Business, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

![Chris The Dev](https://raw.githubusercontent.com/chriswakefield87/appstore-screenshot-translator/main/assets/actor-banner.png)

## EIA Energy Data Normalizer

Fetch and normalize US energy data from the **U.S. Energy Information Administration (EIA) API v2**. Get petroleum prices, natural gas, electricity, coal, renewables, and more — with human-readable labels, cleaned fields, and structured JSON output.

**No web scraping required** — pure REST API access to official government energy data. A free API key from eia.gov takes 30 seconds to register.

### Features

- **9 data categories**: Petroleum spot prices, natural gas prices, electricity retail, coal production, renewable generation, total energy, petroleum stocks, natural gas storage, crude oil production
- **Smart normalization**: Fuel type codes → readable names (WTI → "West Texas Intermediate"), region codes → full names (PADD3 → "Gulf Coast"), unit codes → labels (MWH → "Megawatt-hours")
- **Flexible filtering**: By state, date range, result count
- **Three output formats**: Dataset (JSON), human-readable summary table, and machine-readable statistics
- **Free data source**: EIA API v2 — register at eia.gov/opendata for a free key

### Input Parameters

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `apiKey` | string | ✅ | — | Free API key from [eia.gov/opendata/register.php](https://www.eia.gov/opendata/register.php) |
| `dataCategory` | select | ✅ | `petroleum-prices` | Which EIA data category to fetch |
| `stateFilter` | string | ❌ | — | 2-letter US state code (e.g. TX, CA) |
| `maxResults` | integer | ❌ | 100 | Maximum data points (1–5000) |
| `dateFrom` | string | ❌ | — | Start date in YYYY-MM format |
| `dateTo` | string | ❌ | — | End date in YYYY-MM format |

#### Data Categories

| Value | Label |
|---|---|
| `petroleum-prices` | Petroleum Spot Prices (WTI, Brent, etc.) |
| `natural-gas-prices` | Natural Gas Prices (Henry Hub, citygate) |
| `electricity-retail` | Electricity Retail Sales (by state/sector) |
| `coal-production` | Coal Production (by region/mine type) |
| `renewable-generation` | Renewable Energy Generation (solar, wind, hydro) |
| `total-energy` | Total Energy Overview (consumption, production) |
| `petroleum-stocks` | Petroleum Stocks (inventories, SPR) |
| `natural-gas-storage` | Natural Gas Storage (weekly) |
| `crude-oil-production` | Crude Oil Production (by state/region) |

### Example Input

```json
{
  "apiKey": "YOUR_EIA_API_KEY",
  "dataCategory": "petroleum-prices",
  "maxResults": 20,
  "dateFrom": "2025-01",
  "dateTo": "2025-06"
}
```

### Example Output

```
=====================================================================================
  EIA ENERGY DATA — Petroleum Spot Prices
=====================================================================================
  Retrieved:     20 data points
  Period range:  2025-06 → 2025-01
  Fuel types:    Brent Crude, West Texas Intermediate
  Regions:       United States

  #  Period      Fuel/Product                    Value         Unit               Region
───  ──────────  ─────────────────────────  ────────────  ──────────────────  ────────────────────
  1  2025-06     West Texas Intermediate          72.34     USD                 United States
  2  2025-05     West Texas Intermediate          68.91     USD                 United States
  3  2025-04     West Texas Intermediate          65.22     USD                 United States
  ...
```

Each dataset item contains: `period`, `year`, `month`, `value`, `unit`, `fuel`, `region`, `sector`, and `seriesDescription` (where available).

### Use Cases

- **Energy traders & analysts** — Track spot prices across crude, gas, and products
- **Commodity researchers** — Historical price trends with normalized labels
- **ESG & sustainability teams** — Renewable generation data by state and fuel type
- **Economic researchers** — Energy cost inputs for inflation/economic models
- **AI/ML pipelines** — Clean, structured energy data for training and analysis
- **Supply chain & logistics** — Fuel price trends by region for cost forecasting

### Data Source

Data sourced from the [U.S. Energy Information Administration (EIA) Open Data API v2](https://www.eia.gov/opendata/). The EIA is the statistical agency of the U.S. Department of Energy, providing independent and impartial energy data. All data is public domain and freely redistributable.

**Free API key**: Register at [eia.gov/opendata/register.php](https://www.eia.gov/opendata/register.php) — instant activation, generous free tier.

# Actor input Schema

## `apiKey` (type: `string`):

Free API key from https://www.eia.gov/opendata/register.php

## `dataCategory` (type: `string`):

Which EIA data category to fetch and normalize

## `stateFilter` (type: `string`):

Optional: 2-letter US state code (e.g. TX, CA) or leave empty for all US

## `maxResults` (type: `integer`):

Max number of data points to return

## `dateFrom` (type: `string`):

Optional: start date in YYYY-MM format (e.g. 2024-01)

## `dateTo` (type: `string`):

Optional: end date in YYYY-MM format (e.g. 2024-12)

## Actor input object example

```json
{
  "dataCategory": "petroleum-prices",
  "maxResults": 100
}
```

# Actor output Schema

## `results` (type: `string`):

All normalized energy data points as JSON array.

## `summary` (type: `string`):

Human-readable formatted summary table.

## `stats` (type: `string`):

Machine-readable statistics and metadata.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "stateFilter": "",
    "dateFrom": "",
    "dateTo": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("wakey7dev/eia-energy-normalizer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "stateFilter": "",
    "dateFrom": "",
    "dateTo": "",
}

# Run the Actor and wait for it to finish
run = client.actor("wakey7dev/eia-energy-normalizer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "stateFilter": "",
  "dateFrom": "",
  "dateTo": ""
}' |
apify call wakey7dev/eia-energy-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wakey7dev/eia-energy-normalizer"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/x8lgbbktnegpTgTzG/builds/G5mwZiTGhRYVpyaAe/openapi.json
