> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# US Energy Information Administration

> US energy statistics (electricity, petroleum, natural gas, coal, prices, production, consumption) from the EIA Open Data API v2.

![](https://mintcdn.com/webrouter/gPu3tCeozwRcDBjt/logo/data-apis/eia.webp?fit=max\&auto=format\&n=gPu3tCeozwRcDBjt\&q=85\&s=9e4d80103d8786104b02e9f6086cb40e)

[Web Catalog · Finance](https://docs.webrouter.net/data-apis.md?category=finance)

Needs&#x20;

`EIA_API_KEY`

Endpoints

8

Auth

Key in query

[Vendor docs](https://www.eia.gov/opendata/documentation.php)

## Setup

| Variable | | What it is |
| - | - | - |
| `EIA_API_KEY` | required | a free EIA Open Data API key (register at eia.gov/opendata). Sent as the api\_key query parameter. |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* The API is a tree of routes: call a route without /data for its metadata (child routes, or frequencies, facets and data columns), then add /data to get rows.
* Data rows only carry value columns that are asked for with data\[]; ask for them explicitly.
* JSON answers hold at most 5,000 rows; page with offset and length. response.total gives the full match count.
* Bulk scraping must be throttled; a key that sends too many requests per second or hour is suspended temporarily.
* Route segments go in separate path parameters (category, dataset); a value containing '/' would be escaped.

## Endpoints

GET

List top-level datasets

The API's top-level routes (electricity, petroleum, natural-gas, ...).

[Open](#eia-routes-list)

GET

Get a route

A route's description and child routes, or, for a dataset route, its frequencies, facets and data columns.

[Open](#eia-route-get)

GET

Get a second-level route

Metadata of a route two levels deep: child routes, or frequencies, facets and data columns.

[Open](#eia-dataset-get)

GET

List a facet's values

The codes a facet accepts in a dataset two levels deep (e.g. sectorid: RES, COM).

[Open](#eia-facet-values)

GET

Query a dataset two levels deep

Rows of a dataset at /\{category}/\{dataset}, e.g. electricity/retail-sales.

[Open](#eia-data-get)

GET

Query a dataset three levels deep

Rows of a dataset at /\{category}/\{subcategory}/\{dataset}; walk eia.route.get to find such routes.

[Open](#eia-data-get3)

GET

Query electricity retail sales

Electricity sales to ultimate customers by state and sector: customers, average price, revenue and MWh sold.

[Open](#eia-electricity-retail-sales)

GET

Get a legacy APIv1 series

Data for an APIv1 series id, translated to its v2 dataset.

[Open](#eia-series-get)

### List top-level datasets

GET

`/`

`eia.routes.list`

The API's top-level routes (electricity, petroleum, natural-gas, ...).

Input

No inputs.

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-surveys-list), [IBGE](https://docs.webrouter.net/data-apis/ibge.md#ibge-aggregates-list), [World Bank Indicators API](https://docs.webrouter.net/data-apis/worldbank.md#worldbank-topics-list)

```python Python theme={null}
router.call_data_api("eia.routes.list")
```

```text MCP theme={null}
call_data_api(endpoint="eia.routes.list")
```

### Get a route

GET

`/{category}`

`eia.route.get`

A route's description and child routes, or, for a dataset route, its frequencies, facets and data columns.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`category` required</td><td>string</td><td>path</td><td>Top-level route. Example `electricity`</td></tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-surveys-get)

```python Python theme={null}
router.call_data_api("eia.route.get", {'category': 'electricity'})
```

```text MCP theme={null}
call_data_api(endpoint="eia.route.get", params={"category": "electricity"})
```

### Get a second-level route

GET

`/{category}/{dataset}`

`eia.dataset.get`

Metadata of a route two levels deep: child routes, or frequencies, facets and data columns.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`category` required</td><td>string</td><td>path</td><td>Top-level route. Example `electricity`</td></tr>
    <tr><td>`dataset` required</td><td>string</td><td>path</td><td>Route under it. Example `retail-sales`</td></tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-surveys-get)

```python Python theme={null}
router.call_data_api("eia.dataset.get", {'category': 'electricity', 'dataset': 'retail-sales'})
```

```text MCP theme={null}
call_data_api(endpoint="eia.dataset.get", params={"category": "electricity", "dataset": "retail-sales"})
```

### List a facet's values

GET

`/{category}/{dataset}/facet/{facet_id}`

`eia.facet.values`

The codes a facet accepts in a dataset two levels deep (e.g. sectorid: RES, COM).

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`category` required</td><td>string</td><td>path</td><td>Top-level route. Example `electricity`</td></tr>
    <tr><td>`dataset` required</td><td>string</td><td>path</td><td>Dataset route. Example `retail-sales`</td></tr>
    <tr><td>`facet_id` required</td><td>string</td><td>path</td><td>Facet id from the dataset's metadata. Example `sectorid`</td></tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-surveys-get)

```python Python theme={null}
router.call_data_api("eia.facet.values", {'category': 'electricity', 'dataset': 'retail-sales', 'facet_id': 'sectorid'})
```

```text MCP theme={null}
call_data_api(endpoint="eia.facet.values", params={"category": "electricity", "dataset": "retail-sales", "facet_id": "sectorid"})
```

### Query a dataset two levels deep

GET

`/{category}/{dataset}/data`

`eia.data.get`

Rows of a dataset at /\{category}/\{dataset}, e.g. electricity/retail-sales.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`category` required</td><td>string</td><td>path</td><td>Top-level route. Example `electricity`</td></tr>
    <tr><td>`dataset` required</td><td>string</td><td>path</td><td>Dataset route under it. Example `retail-sales`</td></tr>
    <tr><td>`data`</td><td>array</td><td>query</td><td>Value columns to return (the dataset's metadata lists them). Without it, rows carry no values. Example `["price"]`</td></tr>
    <tr><td>`frequency`</td><td>string</td><td>query</td><td>Periodicity the dataset offers, e.g. monthly, quarterly, annual. Example `monthly`</td></tr>
    <tr><td>`start`</td><td>string</td><td>query</td><td>First period, in the frequency's format (YYYY-MM for monthly). Example `2020-01`</td></tr>
    <tr><td>`end`</td><td>string</td><td>query</td><td>Last period. Example `2024-12`</td></tr>
    <tr><td>`sort_column`</td><td>string</td><td>query</td><td>Column to sort by. Example `period`</td></tr>

    <tr>
      <td>
        `sort_direction`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        &#x20;One of&#x20;

        `asc`

        ,&#x20;

        `desc`
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to skip.
      </td>
    </tr>

    <tr>
      <td>
        `length`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to return; at most 5,000 in JSON.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-series-get), [IBGE](https://docs.webrouter.net/data-apis/ibge.md#ibge-aggregates-values), [World Bank Indicators API](https://docs.webrouter.net/data-apis/worldbank.md#worldbank-indicator-data)

```python Python theme={null}
router.call_data_api("eia.data.get", {'category': 'electricity', 'dataset': 'retail-sales', 'data': ['price'], 'frequency': 'monthly', 'start': '2020-01', 'end': '2024-12', 'sort_column': 'period'})
```

```text MCP theme={null}
call_data_api(endpoint="eia.data.get", params={"category": "electricity", "dataset": "retail-sales", "data": ["price"], "frequency": "monthly", "start": "2020-01", "end": "2024-12", "sort_column": "period"})
```

> [!NOTE]
>
> * Facet filters (facets\[\<id>]\[]=\<code>) have dynamic names; this entry cannot take them. Use eia.electricity.retail\_sales, or a raw call with the facet in the query.

### Query a dataset three levels deep

GET

`/{category}/{subcategory}/{dataset}/data`

`eia.data.get3`

Rows of a dataset at /\{category}/\{subcategory}/\{dataset}; walk eia.route.get to find such routes.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `category`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Top-level route.
      </td>
    </tr>

    <tr>
      <td>
        `subcategory`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Second-level route.
      </td>
    </tr>

    <tr>
      <td>
        `dataset`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        Dataset route under it.
      </td>
    </tr>

    <tr><td>`data`</td><td>array</td><td>query</td><td>Value columns to return (the dataset's metadata lists them). Without it, rows carry no values. Example `["price"]`</td></tr>
    <tr><td>`frequency`</td><td>string</td><td>query</td><td>Periodicity the dataset offers, e.g. monthly, quarterly, annual. Example `monthly`</td></tr>
    <tr><td>`start`</td><td>string</td><td>query</td><td>First period, in the frequency's format (YYYY-MM for monthly). Example `2020-01`</td></tr>
    <tr><td>`end`</td><td>string</td><td>query</td><td>Last period. Example `2024-12`</td></tr>
    <tr><td>`sort_column`</td><td>string</td><td>query</td><td>Column to sort by. Example `period`</td></tr>

    <tr>
      <td>
        `sort_direction`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        &#x20;One of&#x20;

        `asc`

        ,&#x20;

        `desc`
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to skip.
      </td>
    </tr>

    <tr>
      <td>
        `length`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to return; at most 5,000 in JSON.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-series-get), [IBGE](https://docs.webrouter.net/data-apis/ibge.md#ibge-aggregates-values), [World Bank Indicators API](https://docs.webrouter.net/data-apis/worldbank.md#worldbank-indicator-data)

> [!NOTE]
>
> * Facet filters need a raw call, as for eia.data.get.

### Query electricity retail sales

GET

`/electricity/retail-sales/data`

`eia.electricity.retail_sales`

Electricity sales to ultimate customers by state and sector: customers, average price, revenue and MWh sold.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`data`</td><td>array</td><td>query</td><td>Value columns to return (the dataset's metadata lists them). Without it, rows carry no values. Example `["price"]`</td></tr>
    <tr><td>`frequency`</td><td>string</td><td>query</td><td>Periodicity the dataset offers, e.g. monthly, quarterly, annual. Example `monthly`</td></tr>
    <tr><td>`start`</td><td>string</td><td>query</td><td>First period, in the frequency's format (YYYY-MM for monthly). Example `2020-01`</td></tr>
    <tr><td>`end`</td><td>string</td><td>query</td><td>Last period. Example `2024-12`</td></tr>
    <tr><td>`sort_column`</td><td>string</td><td>query</td><td>Column to sort by. Example `period`</td></tr>

    <tr>
      <td>
        `sort_direction`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        &#x20;One of&#x20;

        `asc`

        ,&#x20;

        `desc`
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to skip.
      </td>
    </tr>

    <tr>
      <td>
        `length`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Rows to return; at most 5,000 in JSON.
      </td>
    </tr>

    <tr><td>`stateid`</td><td>array</td><td>query</td><td>State codes to keep. Example `["CO"]`</td></tr>
    <tr><td>`sectorid`</td><td>array</td><td>query</td><td>Sector codes to keep (RES residential, COM commercial, ...). Example `["RES"]`</td></tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-series-get), [IBGE](https://docs.webrouter.net/data-apis/ibge.md#ibge-aggregates-values), [World Bank Indicators API](https://docs.webrouter.net/data-apis/worldbank.md#worldbank-indicator-data)

```python Python theme={null}
router.call_data_api("eia.electricity.retail_sales", {'data': ['price'], 'frequency': 'monthly', 'start': '2020-01', 'end': '2024-12', 'sort_column': 'period', 'stateid': ['CO'], 'sectorid': ['RES']})
```

```text MCP theme={null}
call_data_api(endpoint="eia.electricity.retail_sales", params={"data": ["price"], "frequency": "monthly", "start": "2020-01", "end": "2024-12", "sort_column": "period", "stateid": ["CO"], "sectorid": ["RES"]})
```

> [!NOTE]
>
> * Example: data \[price], stateid \[CO], sectorid \[RES], frequency monthly gives Colorado's residential price per month.

### Get a legacy APIv1 series

GET

`/seriesid/{series_id}`

`eia.series.get`

Data for an APIv1 series id, translated to its v2 dataset.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`series_id` required</td><td>string</td><td>path</td><td>APIv1 series id. Example `ELEC.SALES.CO-RES.A`</td></tr>
  </tbody>
</table>

[Vendor docs](https://www.eia.gov/opendata/documentation.php) · Same job: [US Bureau of Labor Statistics](https://docs.webrouter.net/data-apis/bls.md#bls-series-get), [IBGE](https://docs.webrouter.net/data-apis/ibge.md#ibge-aggregates-values), [World Bank Indicators API](https://docs.webrouter.net/data-apis/worldbank.md#worldbank-indicator-data)

```python Python theme={null}
router.call_data_api("eia.series.get", {'series_id': 'ELEC.SALES.CO-RES.A'})
```

```text MCP theme={null}
call_data_api(endpoint="eia.series.get", params={"series_id": "ELEC.SALES.CO-RES.A"})
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.