# US Energy Data API (`he_work/us-energy-data`) Actor

Fetches energy statistics from the US Energy Information Administration (EIA) Open Data API. Returns electricity sales, generation, and pricing data by state and sector. Zero competition on Apify Store.

- **URL**: https://apify.com/he_work/us-energy-data.md
- **Developed by:** [HE Work](https://apify.com/he_work) (community)
- **Categories:** Business, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.68 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## US Energy Data API

> ✅ **Checked daily.** An automated test runs this Actor on the Apify cloud every day and checks that it still returns real data, so if the website changes and something breaks, it's caught the same day and fixed.

Fetches energy statistics from the US Energy Information Administration (EIA) Open Data API. Returns electricity sales and generation data by state and sector.

### Features

- **Electricity sales** — Monthly retail sales data by state
- **Electricity generation** — Monthly generation data
- **State/sector filters** — Filter by state and sector
- **Free API key** — Get your key at eia.gov/opendata (DEMO_KEY works for limited use)

### Input

| Field | Type | Description | Default |
|-------|------|-------------|---------|
| `apiKey` | string (secret, stored encrypted) | Your EIA API key; empty = EIA's public `DEMO_KEY` | – |
| `categories` | string | Comma-separated: electricity_sales, electricity_gen | `electricity_sales` |
| `state` | string | Two-letter state code (empty = all) | \`\` |
| `maxRecords` | integer | Max records per category | `100` |

### Example input

```json
{
  "maxRecords": 10,
  "categories": "electricity_sales",
  "state": ""
}
```

### Example output

One item from a real run (long texts shortened):

```json
{
  "period": "2026-08",
  "category": "electricity_sales",
  "source": "us-eia",
  "scrapedAt": "2026-11-05T07:36:43.056485+00:00",
  "state": "AK",
  "stateName": "Alaska",
  "sector": "OTH",
  "sectorName": "other",
  "value": "0",
  "unit": "million kilowatt hours"
}
```

### How it compares

| | This Actor | Typical alternative |
|---|---|---|
| Fields per result | 10 (see *Example output*) | Varies by actor |
| Freshness | Read live from the source when the run starts | Varies |
| Reliability | Tested daily by an automated run on the Apify cloud (see the top of this page) | — |
| Price | $0.80 per 1,000 records | No comparable Actor on the Apify Store (6 Nov 2026); the alternative is the source's own API or export, or collecting it by hand |

### Pricing

Pay per result, no monthly fee:

- **$0.80 per 1,000 records**: One record delivered to your dataset.
- $0.0005 per run (start).

Bronze plans pay 5% less, Silver 10% less, Gold and above 15% less.

**Examples:** 1,000 records = $0.80; 10,000 = $8.00.

### FAQ

**How do I run it on a schedule?** Create a task with your input and add a schedule in Apify Console (e.g. daily at 6 am). Each run writes a fresh dataset.

**How do I get the data?** Download the dataset as JSON, CSV, Excel, XML or HTML from the run page, or read it with the Apify API / Python and JavaScript clients. Integrations (Google Sheets, Make, Zapier, n8n, webhooks) work out of the box.

**Do I need an account or API key?** Some data sources need a free API key, entered in the input; everything else (proxies, retries) is handled inside the Actor.

**What if a run returns fewer results than expected?** Check the run's key-value store `OUTPUT` record (when present) for a per-request report, then open an issue on the Issues tab with the run link and we'll look into it.

**Is it legal?** The Actor only collects publicly available data. You are responsible for using it in line with the website's terms, copyright and data-protection rules (GDPR, CCPA) — don't collect personal data you have no legal basis for.

# Actor input Schema

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

Your EIA Open Data API key (free at https://www.eia.gov/opendata/). Stored encrypted. Leave empty to use EIA's public DEMO_KEY (low rate limit).

## `categories` (type: `string`):

Comma-separated categories: electricity_sales, electricity_gen

## `state` (type: `string`):

Two-letter state code (e.g. CA, TX). Leave empty for all states.

## `maxRecords` (type: `integer`):

Maximum records to return per category

## Actor input object example

```json
{
  "categories": "electricity_sales",
  "state": "",
  "maxRecords": 10
}
```

# Actor output Schema

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

Dataset with one item per result.

## `storage` (type: `string`):

Key-value store of the run (run summary, if any).

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("he_work/us-energy-data").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("he_work/us-energy-data").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 '{}' |
apify call he_work/us-energy-data --silent --output-dataset

```

## MCP server setup

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

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/YfjCL2bfjdukR06rW/builds/jp85f8QP4f37OabJ4/openapi.json
