Tutorial

ENTSO-E API in Python: European energy data analysis

Automate your European energy analyses with Python and the ENTSO-E API. We explain step by step with practical examples.

ENTSO-E API in Python: European energy data analysis

When comparing Spain ES with Italy IT_SACO_AC, we observe that the increase in the hourly price of electricity in Spain takes longer to arrive.

Hourly analysis of electricity prices in Europe, showing how geographic position and solar generation affect energy prices.
F1. Hourly Comparison of Electricity Prices in Europe.

One of the reasons is that solar generation reduces the price of electricity.

Although both countries are in the same time zone, Italy is further east than Spain, so the sun sets earlier in Italy than in Spain.

In this tutorial, we’ll explain how to download European energy data through the ENTSO-E API and analyze it with Python.

Want a simpler approach? We’ve published python-entsoe — a Python library that wraps everything in this tutorial into simple function calls. Read the announcement →

Questions

  1. How to access the ENTSO-E API to download European energy data?
  2. Which function is used to download generation data?
  3. And electricity prices?
  4. How to use area codes to download data by country?
  5. How are data grouped to perform hourly comparisons?
  6. How to download multiple market areas at once?

Methodology

Getting access token

To programmatically download data from ENTSO-E, you need an access token.

  1. Sign up on ENTSO-E
  2. Go to My Account
  3. Access Web API Access
  4. Generate your token
API_TOKEN = 'YOUR_TOKEN'

To work with the ENTSO-E API in Python, we recommend using python-entsoe, a modern library that provides a cleaner interface and better developer experience. Check out our full tutorial on python-entsoe for more details.

pip install python-entsoe
from entsoe import ENTSOEClient

client = ENTSOEClient()

Downloading generation by technology in Italy

To get started, we’re going to download the data on generation by technology in Italy during February 2024.

start = "2024-02-01"
end = "2024-02-29"

df = client.generation.actual(start, end, country="IT")
Energy generation data by technology in Italy during February 2024, showing the distribution of sources such as solar, wind, and conventional.
F2. Energy Generation by Technology in Italy.

Hourly comparison of generation by technology

As usual, we’re going to create a heat matrix to highlight the differences in generation by technology in Italy according to the time of day.

df['hour'] = df['timestamp'].dt.hour
df.groupby(['hour']).sum()

Given that there are not many hours of sunlight in February, solar generation was only significant for a few hours, from 9 to 15.

Heat matrix representing generation by technology in Italy throughout the day, showing the hours of highest solar production.
F3. Heat Matrix of Energy Generation in Italy.

Downloading electricity prices by area in Europe

We’re going to level up: we’ll download the electricity prices by area in Europe.

Visualization of electricity prices by market area in Europe during February 2024, with data downloaded using the ENTSO-E API.
F4. Electricity Prices by Area in Europe.

For this, we pass a list of country codes directly — the library handles the iteration and adds a country column automatically.

Advanced content
Sign up free to unlock

Conclusions

  1. Accessing the ENTSO-E API: ENTSOEClient() from python-entsoe provides a clean interface to download data and analyze it with pandas.
  2. Downloading generation data: client.generation.actual() to download energy generation data by technology from a specific country.
  3. Downloading electricity prices: client.prices.day_ahead() to get electricity prices for a specific market area.
  4. Using area codes for country data: country parameter to specify the market area from which we want to download the data.
  5. Grouping data for hourly comparisons: extracting the hour from timestamps and using groupby to aggregate values applying a mathematical function.
  6. Downloading multiple market areas: pd.concat to concatenate multiple indicators downloaded after iterating over a list of area codes.

Keep reading

Related articles you might enjoy

Table of Contents
Search sections

Subscribe to our newsletter

Get weekly insights on data, automation, and AI.

© 2026 Datons. All rights reserved.