ENTSO-E Python API Wrapper

0.8.0 · active · verified Thu Apr 16

entsoe-py is a Python API wrapper for the ENTSO-E Transparency Platform. It simplifies querying electricity data such as day-ahead prices, generation, and capacity, primarily returning data as pandas DataFrames. The library is actively maintained, with version 0.8.0 being the latest, and sees regular updates to address API changes and add new functionality.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the EntsoePandasClient with an API key, preferably from an environment variable, and demonstrates how to query day-ahead electricity prices for a specified country and date range. The result is a pandas Series.

import os
from entsoe import EntsoePandasClient
import pandas as pd

# Ensure you have an ENTSO-E API key from https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/API%20Documentation.html
# Set it as an environment variable or pass directly: api_key='YOUR_API_KEY'
api_key = os.environ.get('ENTSOE_API_KEY', '')

if not api_key:
    print("Warning: ENTSOE_API_KEY environment variable not set. Using a placeholder.")
    print("Please obtain a key from ENTSO-E and set it before running.")
    # Use a dummy key if not set, for the example to at least initialize
    # In a real scenario, this would likely cause an authentication error later.
    api_key = "dummy_api_key_for_example"

client = EntsoePandasClient(api_key=api_key)

start = pd.Timestamp('20230101', tz='Europe/Brussels')
end = pd.Timestamp('20230102', tz='Europe/Brussels')
country_code = 'BE'

try:
    # Query day-ahead prices for Belgium
    day_ahead_prices = client.query_day_ahead_prices(country_code, start=start, end=end)
    print(f"Day-ahead prices for {country_code} (first 5 rows):\n{day_ahead_prices.head()}")
except Exception as e:
    print(f"An error occurred during API query: {e}")
    print("Please ensure your API key is correct and valid, and the country code/date range are supported.")

view raw JSON →