Energy and environment

EIA Open Data API

by eia.gov

Energy and environment Added on November 7th, 2026 Checked and working on November 7th, 2026
Visit eia.gov →

What it does

The EIA Open Data API from the US Energy Information Administration gives energy statistics: electricity generation and prices, oil and gas production and prices, coal, renewables and forecasts, for example to chart US petrol prices. Browse routes such as /v2/electricity/retail-sales and get JSON. Free with a free API key.
  • API
  • HTTP-GET
  • JSON
  • REST

At a glance

API key
Needed, free · More APIs with a free key
Pricing
Free with a free API key.
From the browser
Yes (CORS)
Formats
JSON
Interface
REST, HTTP-GET
Provider
eia.gov
Last checked
Working on November 7th, 2026

More information: https://www.eia.gov/opendata/

Is this your service? Show that it is listed

Put this badge on your website or in your README; it links to this page. About the badge

Listed on Free Web Services

eia.gov
EIA Open Data API

Example request

curl

curl 'https://api.eia.gov/v2/electricity/retail-sales/data/?api_key=YOUR_API_KEY&frequency=monthly&data[0]=price&length=5'

JavaScript

const response = await fetch("https://api.eia.gov/v2/electricity/retail-sales/data/?api_key=YOUR_API_KEY&frequency=monthly&data[0]=price&length=5");
const data = await response.json();
console.log(data);

Python

import requests

response = requests.get(
    "https://api.eia.gov/v2/electricity/retail-sales/data/?api_key=YOUR_API_KEY&frequency=monthly&data[0]=price&length=5",
    timeout=30,
)
print(response.json())

Replace YOUR_API_KEY with your own key. The JavaScript works in a web page as well as in Node.js 18 or newer.

Did it work for you?

Tell us what you found when you tried EIA Open Data API.