Check the Setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- A free Ember API key saved in the EMBER_API_KEY environment variable
Open country electricity generation, demand, and carbon-intensity series for building energy-transition comparison and power-mix monitoring tools.
Report a ProblemFrom Source to Product Signal
Ember publishes compiled country electricity statistics through a REST API. Start with yearly generation for one country and a few recent years. This is not a live grid feed — U.S. operations belong on EIA hourly data and EU transparency on ENTSO-E — and monthly coverage is limited to a subset of countries.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import os
import pandas as pd
import requests
response = requests.get(
"https://api.ember-energy.org/v1/electricity-generation/yearly",
params={
"entity_code": "USA",
"is_aggregate_series": "false",
"start_date": "2020",
"api_key": os.environ["EMBER_API_KEY"],
},
timeout=30,
)
response.raise_for_status()
generation = pd.json_normalize(response.json().get("data", response.json()))
generation["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(generation.head(20))Test a Useful Signal
Test whether Ember yearly generation can power a bounded energy-transition comparison.
Ember is a nonprofit source. Last verified 2026-08-20. Temporal coverage: yearly series from 2000-present with monthly coverage for a smaller country set.