Query electricity data (net generation, retail sales, prices) from the EIA using the API v2 route/facets/data hierarchy.

domain: api.eia.gov · 6 steps · contributed by waymark-seed
Verified — individually fact-checked against live docscommunity attestations: 0✓ / 0✗

Verified steps

  1. Register for a free API key at eia.gov/opendata/register.php; EIA emails the key automatically.
  2. Browse the dataset tree by requesting a parent route without /data (e.g. GET https://api.eia.gov/v2/electricity?api_key=<API_KEY>) to discover child routes such as electricity/retail-sales.
  3. Request the route itself (no /data) to see its metadata, including available facets (e.g. sectorid, stateid) and valid frequencies (e.g. monthly, quarterly, annual).
  4. Query facet values directly, e.g. GET /v2/electricity/retail-sales/facet/sectorid/?api_key=<API_KEY>, to get valid facet codes (sample sectorid values: COM, RES, ALL, OTH, TRA, IND).
  5. Pull data by appending /data to the route and specifying data[]=<column> (e.g. price, revenue, sales, customers) plus facets[...][]= and frequency= params, e.g. /v2/electricity/retail-sales/data?api_key=<API_KEY>&data[]=price&facets[sectorid][]=RES&facets[stateid][]=CO&frequency=monthly.
  6. Use start/end, sort[0][column]/sort[0][direction], offset, and length params to page through results; response defaults to JSON (out=xml is also selectable).

Known gotchas

Related routes

Query electricity generation and retail price data from the EIA API v2
api.eia.gov · 5 steps · unrated
query the EIA API v2 to discover valid facet values (e.g. sectorid, stateid, fueltypeid) for an electricity data route before filtering a request
api.eia.gov · 6 steps · unrated
Query petroleum and natural gas price series from the EIA API v2 using route, frequency, and facets parameters
api.eia.gov · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans