### Install entsoe-py Source: https://context7.com/energieid/entsoe-py/llms.txt Install the entsoe-py library using pip. ```bash python3 -m pip install entsoe-py ``` -------------------------------- ### Initialize EntsoePandasClient and Query Data Source: https://github.com/energieid/entsoe-py/blob/master/README.md Initializes the EntsoePandasClient with an API key and demonstrates various query methods for different types of energy market data. Requires pandas Timestamps with timezone information for start and end parameters. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key=) start = pd.Timestamp('20171201', tz='Europe/Brussels') end = pd.Timestamp('20180101', tz='Europe/Brussels') country_code = 'BE' # Belgium country_code_from = 'FR' # France country_code_to = 'DE_LU' # Germany-Luxembourg type_marketagreement_type = 'A01' contract_marketagreement_type = "A01" process_type = 'A51' # methods that return Pandas Series client.query_day_ahead_prices(country_code, start=start, end=end) client.query_aggregated_bids(country_code, start=start, end=end, process_type) client.query_net_position(country_code, start=start, end=end, dayahead=True) client.query_crossborder_flows(country_code_from, country_code_to, start=start, end=end) client.query_scheduled_exchanges(country_code_from, country_code_to, start=start, end=end, dayahead=False) client.query_net_transfer_capacity_dayahead(country_code_from, country_code_to, start=start, end=end) client.query_net_transfer_capacity_weekahead(country_code_from, country_code_to, start=start, end=end) client.query_net_transfer_capacity_monthahead(country_code_from, country_code_to, start=start, end=end) client.query_net_transfer_capacity_yearahead(country_code_from, country_code_to, start=start, end=end) client.query_intraday_offered_capacity(country_code_from, country_code_to, start=start, end=end, implicit=True) client.query_offered_capacity(country_code_from, country_code_to, contract_marketagreement_type, start=start, end=end, implicit=True) client.query_aggregate_water_reservoirs_and_hydro_storage(country_code, start=start, end=end) # methods that return Pandas DataFrames client.query_load(country_code, start=start, end=end) client.query_load_forecast(country_code, start=start, end=end) client.query_load_and_forecast(country_code, start=start, end=end) client.query_generation_forecast(country_code, start=start, end=end) client.query_wind_and_solar_forecast(country_code, start=start, end=end, psr_type=None) client.query_intraday_wind_and_solar_forecast(country_code, start=start, end=end, psr_type=None) client.query_generation(country_code, start=start, end=end, psr_type=None) client.query_generation_per_plant(country_code, start=start, end=end, psr_type=None, include_eic=False) client.query_installed_generation_capacity(country_code, start=start, end=end, psr_type=None) client.query_installed_generation_capacity_per_unit(country_code, start=start, end=end, psr_type=None) client.query_activated_balancing_energy_prices(country_code, start=start, end=end, process_type='A16', psr_type=None, business_type=None, standard_market_product=None, original_market_product=None) client.query_activated_balancing_energy(country_code, start=start, end=end, business_type, psr_type=None) client.query_imbalance_prices(country_code, start=start, end=end, psr_type=None) client.query_imbalance_volumes(country_code, start=start, end=end, psr_type=None) client.query_contracted_reserve_prices(country_code, type_marketagreement_type, start=start, end=end, psr_type=None) client.query_contracted_reserve_amount(country_code, type_marketagreement_type, start=start, end=end, psr_type=None) client.query_unavailability_of_generation_units(country_code, start=start, end=end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_unavailability_of_production_units(country_code, start, end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_unavailability_transmission(country_code_from, country_code_to, start=start, end=end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_withdrawn_unavailability_of_generation_units(country_code, start, end) client.query_unavailability_of_offshore_grid(area_code, start, end) client.query_physical_crossborder_allborders(country_code, start, end, export=True) client.query_import(country_code, start, end) client.query_generation_import(country_code, start, end) client.query_procured_balancing_capacity(country_code, process_type, start=start, end=end, type_marketagreement_type=None) ``` -------------------------------- ### EntsoePandasClient Usage Source: https://github.com/energieid/entsoe-py/blob/master/README.md This section provides examples of how to use the EntsoePandasClient to query various types of energy data. It covers methods returning Pandas Series and DataFrames, along with necessary setup. ```APIDOC ## EntsoePandasClient Initialization and Basic Usage ### Description Initialize the EntsoePandasClient with your API key and set up time parameters and country codes for data queries. ### Method Initialization and method calls ### Endpoint N/A (Client-side library) ### Parameters - **api_key** (string) - Required - Your ENTSO-E API key. - **start** (pandas.Timestamp) - Required - The start of the time period (must include timezone). - **end** (pandas.Timestamp) - Required - The end of the time period (must include timezone). - **country_code** (string) - Required - The country code for the query. - **country_code_from** (string) - Required - The source country code for cross-border data. - **country_code_to** (string) - Required - The destination country code for cross-border data. - **process_type** (string) - Optional - The process type for certain queries (e.g., 'A51'). - **dayahead** (boolean) - Optional - Flag to indicate day-ahead data. - **implicit** (boolean) - Optional - Flag for implicit capacity. - **psr_type** (string or list) - Optional - Type of physical or non-physical resource. - **business_type** (string) - Optional - Business type for balancing energy. - **standard_market_product** (string) - Optional - Standard market product type. - **original_market_product** (string) - Optional - Original market product type. - **docstatus** (string) - Optional - Document status for unavailability data. - **periodstartupdate** (string) - Optional - Period start update for unavailability data. - **periodendupdate** (string) - Optional - Period end update for unavailability data. - **include_eic** (boolean) - Optional - Whether to include EIC codes. - **area_code** (string) - Required - The area code for offshore grid unavailability. - **export** (boolean) - Optional - Flag to indicate export data. - **type_marketagreement_type** (string) - Required - Type of market agreement. ### Request Example ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='YOUR_API_KEY') start = pd.Timestamp('20171201', tz='Europe/Brussels') end = pd.Timestamp('20180101', tz='Europe/Brussels') country_code = 'BE' country_code_from = 'FR' country_code_to = 'DE_LU' process_type = 'A51' contract_marketagreement_type = 'A01' # Example query for day-ahead prices prices = client.query_day_ahead_prices(country_code, start=start, end=end) ``` ### Response Responses vary depending on the method called. Methods typically return Pandas Series or DataFrames containing the requested energy data. #### Success Response (200) - **Data** (Pandas Series or DataFrame) - Contains the queried energy data. #### Response Example ```python # Example response for query_day_ahead_prices (Pandas Series) # Output will be a time series of prices ``` ## Specific Data Query Methods ### Description This section lists various methods available in EntsoePandasClient to query specific types of energy data, categorized by whether they return a Pandas Series or DataFrame. ### Methods Returning Pandas Series - **query_day_ahead_prices**: Retrieves day-ahead electricity prices. - **query_aggregated_bids**: Retrieves aggregated bids. - **query_net_position**: Retrieves net position data. - **query_crossborder_flows**: Retrieves cross-border electricity flow data. - **query_scheduled_exchanges**: Retrieves scheduled cross-border electricity exchanges. - **query_net_transfer_capacity_dayahead**: Retrieves day-ahead net transfer capacity. - **query_net_transfer_capacity_weekahead**: Retrieves week-ahead net transfer capacity. - **query_net_transfer_capacity_monthahead**: Retrieves month-ahead net transfer capacity. - **query_net_transfer_capacity_yearahead**: Retrieves year-ahead net transfer capacity. - **query_intraday_offered_capacity**: Retrieves intraday offered capacity. - **query_offered_capacity**: Retrieves offered capacity. - **query_aggregate_water_reservoirs_and_hydro_storage**: Retrieves aggregate water reservoirs and hydro storage data. ### Methods Returning Pandas DataFrames - **query_load**: Retrieves load data. - **query_load_forecast**: Retrieves load forecast data. - **query_load_and_forecast**: Retrieves both load and load forecast data. - **query_generation_forecast**: Retrieves generation forecast data. - **query_wind_and_solar_forecast**: Retrieves wind and solar generation forecast data. - **query_intraday_wind_and_solar_forecast**: Retrieves intraday wind and solar generation forecast data. - **query_generation**: Retrieves generation data. - **query_generation_per_plant**: Retrieves generation data per plant. - **query_installed_generation_capacity**: Retrieves installed generation capacity. - **query_installed_generation_capacity_per_unit**: Retrieves installed generation capacity per unit. - **query_activated_balancing_energy_prices**: Retrieves activated balancing energy prices. - **query_activated_balancing_energy**: Retrieves activated balancing energy data. - **query_imbalance_prices**: Retrieves imbalance prices. - **query_imbalance_volumes**: Retrieves imbalance volumes. - **query_contracted_reserve_prices**: Retrieves contracted reserve prices. - **query_contracted_reserve_amount**: Retrieves contracted reserve amounts. - **query_unavailability_of_generation_units**: Retrieves unavailability of generation units. - **query_unavailability_of_production_units**: Retrieves unavailability of production units. - **query_unavailability_transmission**: Retrieves transmission unavailability data. - **query_withdrawn_unavailability_of_generation_units**: Retrieves withdrawn unavailability of generation units. - **query_unavailability_of_offshore_grid**: Retrieves unavailability of offshore grid data. - **query_physical_crossborder_allborders**: Retrieves physical cross-border data for all borders. - **query_import**: Retrieves import data. - **query_generation_import**: Retrieves generation import data. - **query_procured_balancing_capacity**: Retrieves procured balancing capacity. ### Request Example (DataFrame) ```python # Example query for load data load_data = client.query_load(country_code, start=start, end=end) ``` ### Response Example (DataFrame) ```python # Example response for query_load (Pandas DataFrame) # Output will be a DataFrame with load information ``` ## Dumping Results to File ### Description Demonstrates how to save the queried data to a CSV file using the `.to_csv()` method available on Pandas Series and DataFrames. ### Method `to_csv()` method on Pandas objects. ### Endpoint N/A (Client-side operation) ### Parameters - **path_or_buf** (string) - Required - The file path or buffer to write to. ### Request Example ```python ts = client.query_day_ahead_prices(country_code, start=start, end=end) ts.to_csv('outfile.csv') ``` ### Response No direct API response; the data is saved to a local file. #### Success Response - **File Output**: Data successfully written to the specified CSV file. #### Response Example ``` # A file named 'outfile.csv' will be created in the current directory # containing the queried day-ahead prices. ``` ``` -------------------------------- ### Query Installed Generation Capacity Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves installed generation capacity by fuel type for a specified country and time range. You can also query capacity per generation unit. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20230101', tz='Europe/Brussels') end = pd.Timestamp('20231231', tz='Europe/Brussels') # Query installed capacity for Belgium capacity = client.query_installed_generation_capacity('BE', start=start, end=end) print(capacity.columns.tolist()) # ['Biomass', 'Fossil Gas', 'Hydro Pumped Storage', 'Nuclear', # 'Solar', 'Wind Offshore', 'Wind Onshore', ...] # Query per generation unit capacity_per_unit = client.query_installed_generation_capacity_per_unit( 'BE', start=start, end=end ) ``` -------------------------------- ### Query Physical Cross-Border Flows Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves actual physical electricity flows between two bidding zones. Positive values indicate export from the origin country. Use `query_import` to get all imports to a country. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Paris') end = pd.Timestamp('20231202', tz='Europe/Paris') # Query physical flows from France to Germany-Luxembourg flows_fr_de = client.query_crossborder_flows( country_code_from='FR', country_code_to='DE_LU', start=start, end=end ) # Query flows in opposite direction flows_de_fr = client.query_crossborder_flows( country_code_from='DE_LU', country_code_to='FR', start=start, end=end ) # Get all imports to a country from all neighbors all_imports = client.query_import('FR', start=start, end=end) print(all_imports.columns) # ['BE', 'CH', 'DE_LU', 'ES', 'GB', 'IT_NORD', 'sum'] ``` -------------------------------- ### Load Bidding Zones and Plot Chloropleth Map Source: https://github.com/energieid/entsoe-py/blob/master/entsoe/geo/README.MD Loads bidding zone geometries for specified zones and a given date, assigns a value, and plots a chloropleth map using Plotly. Ensure geopandas, plotly, and pandas are installed. ```python from utils import load_zones import plotly.express as px import pandas as pd zones = ['some', 'ISO2', 'codes'] geo_df = load_zones(zones, pd.Timestamp('somedate')) geo_df['value'] = range(1,len(geo_df)+1) fig = px.choropleth(geo_df, geojson=geo_df.geometry, locations=geo_df.index, color="value", projection="mercator", color_continuous_scale='rainbow') fig.update_geos(fitbounds="locations", visible=False) fig.show() ``` -------------------------------- ### Installed Generation Capacity Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves installed generation capacity by fuel type. ```APIDOC ## query_installed_generation_capacity - Installed Capacity ### Description Retrieves installed generation capacity by fuel type. ### Methods - `query_installed_generation_capacity` - `query_installed_generation_capacity_per_unit` ### Parameters #### Query Parameters (for `query_installed_generation_capacity`) - **country_code** (string) - Required - The country code for which to retrieve installed capacity. - **start** (datetime) - Required - The start of the period. - **end** (datetime) - Required - The end of the period. #### Query Parameters (for `query_installed_generation_capacity_per_unit`) - **country_code** (string) - Required - The country code for which to retrieve installed capacity. - **start** (datetime) - Required - The start of the period. - **end** (datetime) - Required - The end of the period. ### Request Example (Installed capacity by fuel type) ```python capacity = client.query_installed_generation_capacity('BE', start=start, end=end) print(capacity.columns.tolist()) ``` ### Request Example (Installed capacity per unit) ```python capacity_per_unit = client.query_installed_generation_capacity_per_unit( 'BE', start=start, end=end ) ``` ### Response #### Success Response (200) - **capacity** (DataFrame) - A pandas DataFrame containing installed generation capacity. Columns represent fuel types (e.g., 'Biomass', 'Fossil Gas', 'Nuclear', 'Solar', 'Wind Offshore', 'Wind Onshore'). - **capacity_per_unit** (DataFrame) - A pandas DataFrame containing installed generation capacity per unit. ``` -------------------------------- ### Get Neighboring Bidding Zones Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieve a list of neighboring bidding zones for a given area code. Uses a predefined mapping for quick lookups. ```python # Get neighboring bidding zones print(NEIGHBOURS['BE']) # ['NL', 'DE_AT_LU', 'FR', 'GB', 'DE_LU'] ``` -------------------------------- ### Initialize EntsoeFileClient Source: https://github.com/energieid/entsoe-py/blob/master/README.md Instantiate the EntsoeFileClient with your ENTSO-E username and password to access the file library. ```python from entsoe.files import EntsoeFileClient client = EntsoeFileClient(username=, pwd=) ``` -------------------------------- ### Initialize and Use EntsoeRawClient Source: https://context7.com/energieid/entsoe-py/llms.txt Initialize the raw client with an API key and query for day-ahead prices or unavailability data. Raw responses are returned as XML strings or ZIP bytes. ```python from entsoe import EntsoeRawClient import pandas as pd # Initialize client with API key client = EntsoeRawClient(api_key='your-api-key') # Define time range with timezone-aware timestamps start = pd.Timestamp('20231201', tz='Europe/Brussels') end = pd.Timestamp('20231202', tz='Europe/Brussels') # Query day-ahead prices - returns XML string xml_response = client.query_day_ahead_prices('BE', start, end) # Save XML response to file with open('prices.xml', 'w') as f: f.write(xml_response) # Query unavailability data - returns ZIP bytes zip_bytes = client.query_unavailability_of_generation_units('DE_LU', start, end) # Save ZIP response to file with open('unavailability.zip', 'wb') as f: f.write(zip_bytes) ``` -------------------------------- ### Initialize EntsoeRawClient and Query Data Source: https://github.com/energieid/entsoe-py/blob/master/README.md Instantiate the EntsoeRawClient with an API key and demonstrate various methods for querying different types of energy market data, such as day-ahead prices, bids, load, and cross-border flows. Some methods return XML strings, while others return ZIP archives. ```python from entsoe import EntsoeRawClient import pandas as pd client = EntsoeRawClient(api_key=) start = pd.Timestamp('20171201', tz='Europe/Brussels') end = pd.Timestamp('20180101', tz='Europe/Brussels') country_code = 'BE' # Belgium country_code_from = 'FR' # France country_code_to = 'DE_LU' # Germany-Luxembourg type_marketagreement_type = 'A01' contract_marketagreement_type = 'A01' process_type = 'A51' # methods that return XML client.query_day_ahead_prices(country_code, start, end) client.query_aggregated_bids(country_code, start, end, process_type) client.query_net_position(country_code, start, end, dayahead=True) client.query_load(country_code, start, end) client.query_load_forecast(country_code, start, end) client.query_wind_and_solar_forecast(country_code, start, end, psr_type=None) client.query_intraday_wind_and_solar_forecast(country_code, start, end, psr_type=None) client.query_generation_forecast(country_code, start, end) client.query_generation(country_code, start, end, psr_type=None) client.query_generation_per_plant(country_code, start, end, psr_type=None) client.query_installed_generation_capacity(country_code, start, end, psr_type=None) client.query_installed_generation_capacity_per_unit(country_code, start, end, psr_type=None) client.query_crossborder_flows(country_code_from, country_code_to, start, end) client.query_scheduled_exchanges(country_code_from, country_code_to, start, end, dayahead=False) client.query_net_transfer_capacity_dayahead(country_code_from, country_code_to, start, end) client.query_net_transfer_capacity_weekahead(country_code_from, country_code_to, start, end) client.query_net_transfer_capacity_monthahead(country_code_from, country_code_to, start, end) client.query_net_transfer_capacity_yearahead(country_code_from, country_code_to, start, end) client.query_intraday_offered_capacity(country_code_from, country_code_to, start, end, implicit=True) client.query_offered_capacity(country_code_from, country_code_to, start, end, contract_marketagreement_type, implicit=True) client.query_contracted_reserve_prices(country_code, start, end, type_marketagreement_type, psr_type=None) client.query_contracted_reserve_prices_procured_capacity(country_code, start, end, process_type type_marketagreement_type, psr_type=None) client.query_contracted_reserve_amount(country_code, start, end, type_marketagreement_type, psr_type=None) client.query_procured_balancing_capacity(country_code, start, end, process_type, type_marketagreement_type=None) client.query_aggregate_water_reservoirs_and_hydro_storage(country_code, start, end) client.query_activated_balancing_energy_prices(country_code, start, end, process_type='A16', psr_type=None, business_type=None, standard_market_product=None, original_market_product=None) client.query_activated_balancing_energy(country_code, start, end, business_type, psr_type=None) # methods that return ZIP (bytes) client.query_imbalance_prices(country_code, start, end, psr_type=None) client.query_imbalance_volumes(country_code, start=start, end=end, psr_type=None) client.query_unavailability_of_generation_units(country_code, start, end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_unavailability_of_production_units(country_code, start, end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_unavailability_transmission(country_code_from, country_code_to, start, end, docstatus=None, periodstartupdate=None, periodendupdate=None) client.query_unavailability_of_offshore_grid(area_code, start, end) client.query_withdrawn_unavailability_of_generation_units(country_code, start, end) ``` -------------------------------- ### Dump Raw XML or ZIP Data to File Source: https://github.com/energieid/entsoe-py/blob/master/README.md Demonstrates how to save the raw XML string or ZIP bytes returned by specific client methods to local files. Ensure the file is opened in the correct mode ('w' for text, 'wb' for binary). ```python xml_string = client.query_day_ahead_prices(country_code, start, end) with open('outfile.xml', 'w') as f: f.write(xml_string) ``` ```python zip_bytes = client.query_unavailability_of_generation_units(country_code, start, end) with open('outfile.zip', 'wb') as f: f.write(zip_bytes) ``` -------------------------------- ### Configure ENTSO-E Client with Environment Variables Source: https://context7.com/energieid/entsoe-py/llms.txt Configure the ENTSO-E client by setting environment variables for API key, username, password, and custom endpoint URL. The client automatically picks up these variables on initialization. ```python import os # Set API key via environment variable os.environ['ENTSOE_API_KEY'] = 'your-api-key' # Set custom endpoint URL (optional) os.environ['ENTSOE_ENDPOINT_URL'] = 'https://custom-endpoint.example.com/api' # For file client os.environ['ENTSOE_USERNAME'] = 'your-username' os.environ['ENTSOE_PWD'] = 'your-password' # Client will automatically use environment variables from entsoe import EntsoePandasClient client = EntsoePandasClient() # No api_key parameter needed ``` -------------------------------- ### Query Actual Total Load with EntsoePandasClient Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieve actual total electricity load (consumption) data for a specified bidding zone. Returns a DataFrame with load values. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Paris') end = pd.Timestamp('20231202', tz='Europe/Paris') # Query actual load for France load_df = client.query_load('FR', start=start, end=end) print(load_df.head()) # Actual Load # 2023-12-01 00:00:00+01:00 58234.0 # 2023-12-01 00:15:00+01:00 57891.0 # ... ``` -------------------------------- ### Query Day-Ahead Load Forecast with EntsoePandasClient Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieve forecasted electricity load for a specified bidding zone. This snippet also shows how to query actual load and combine both using a utility function. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231210', tz='Europe/Berlin') end = pd.Timestamp('20231211', tz='Europe/Berlin') # Query day-ahead load forecast for Germany-Luxembourg forecast = client.query_load_forecast('DE_LU', start=start, end=end) # Compare with actual load actual = client.query_load('DE_LU', start=start, end=end) # Combine using utility function combined = client.query_load_and_forecast('DE_LU', start=start, end=end) print(combined.columns) # ['Forecasted Load', 'Actual Load'] ``` -------------------------------- ### List Files in Folder Source: https://context7.com/energieid/entsoe-py/llms.txt List available files within a specified folder in the ENTSO-E File Library. Returns a dictionary mapping filenames to unique IDs. ```python # List available files in a folder file_list = client.list_folder('AcceptedAggregatedOffers_17.1.D') print(f"Found {len(file_list)} files") # Returns: {'filename1.csv': 'unique-id-1', 'filename2.csv': 'unique-id-2', ...} ``` -------------------------------- ### Download Single File from ENTSO-E Source: https://github.com/energieid/entsoe-py/blob/master/README.md Download a single file from the ENTSO-E file library by specifying the folder and filename. Requires the file_list to be previously obtained. ```python # either download one file by name: df = client.download_single_file(folder='AcceptedAggregatedOffers_17.1.D', filename=list(file_list.keys())[0]) ``` -------------------------------- ### Initialize and Use EntsoePandasClient Source: https://context7.com/energieid/entsoe-py/llms.txt Initialize the Pandas client with an API key. This client automatically parses API responses into Pandas Series and DataFrames, handling time zones and multi-year queries. ```python from entsoe import EntsoePandasClient import pandas as pd # Initialize client client = EntsoePandasClient(api_key='your-api-key') # Define time range (timezone-aware timestamps required) start = pd.Timestamp('20231201', tz='Europe/Brussels') end = pd.Timestamp('20231208', tz='Europe/Brussels') country_code = 'BE' # Belgium # Query day-ahead prices - returns pd.Series prices = client.query_day_ahead_prices(country_code, start=start, end=end) print(prices.head()) # 2023-12-01 00:00:00+01:00 85.32 # 2023-12-01 01:00:00+01:00 82.15 # ... # Export to CSV prices.to_csv('day_ahead_prices.csv') ``` -------------------------------- ### Query Day-Ahead Market Prices with EntsoePandasClient Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieve day-ahead electricity prices for a specified bidding zone. The result is a timezone-aware Pandas Series. Prices are hourly before October 2025 and 15-minute intervals thereafter. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231215', tz='Europe/Amsterdam') end = pd.Timestamp('20231216', tz='Europe/Amsterdam') # Query for Netherlands prices = client.query_day_ahead_prices('NL', start=start, end=end) # Query for Germany-Luxembourg bidding zone prices_de = client.query_day_ahead_prices('DE_LU', start=start, end=end) # Result is a timezone-aware Pandas Series print(f"Average price: {prices.mean():.2f} EUR/MWh") print(f"Max price: {prices.max():.2f} EUR/MWh") print(f"Min price: {prices.min():.2f} EUR/MWh") ``` -------------------------------- ### Download Multiple Files from ENTSO-E Source: https://github.com/energieid/entsoe-py/blob/master/README.md Download multiple files from the ENTSO-E file library by providing a list of their unique IDs. This is an efficient way to retrieve several files at once. ```python # or download multiple by unique_id: df = client.download_multiple_files(['a1a82b3f-c453-4181-8d20-ad39c948d4b0', '64e47e15-bac6-4212-b2dd-9667bdf33b5d']) ``` -------------------------------- ### Save Query Result to CSV Source: https://github.com/energieid/entsoe-py/blob/master/README.md Demonstrates how to save the results of a data query (e.g., day-ahead prices) to a CSV file using the pandas `to_csv` method. This is useful for local storage and further analysis. ```python ts = client.query_day_ahead_prices(country_code, start=start, end=end) ts.to_csv('outfile.csv') ``` -------------------------------- ### query_load - Actual Total Load Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves actual total electricity load (consumption) data for a specified bidding zone. Returns a DataFrame with load values. ```APIDOC ## POST /api/query_load ### Description Retrieves actual total electricity load (consumption) data for a specified bidding zone. Returns a DataFrame with load values. ### Method POST (or GET, depending on client implementation) ### Endpoint N/A (Client-side abstraction of ENTSO-E REST API) ### Parameters #### Path Parameters None #### Query Parameters - **country_code** (string) - Required - The bidding zone code (e.g., 'FR'). - **start** (pd.Timestamp) - Required - The start of the time range (timezone-aware). - **end** (pd.Timestamp) - Required - The end of the time range (timezone-aware). ### Request Example ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Paris') end = pd.Timestamp('20231202', tz='Europe/Paris') # Query actual load for France load_df = client.query_load('FR', start=start, end=end) print(load_df.head()) # Actual Load # 2023-12-01 00:00:00+01:00 58234.0 # 2023-12-01 00:15:00+01:00 57891.0 # ... ``` ### Response #### Success Response (200) - **Pandas DataFrame** - DataFrame with 'Actual Load' column, indexed by timestamp. ``` -------------------------------- ### Download Raw ZIP Bytes Source: https://context7.com/energieid/entsoe-py/llms.txt Download the raw ZIP bytes of a single file for custom processing. Requires folder and filename. ```python # Download raw ZIP bytes for custom processing raw_bytes = client.download_single_file_raw( folder='AcceptedAggregatedOffers_17.1.D', filename=list(file_list.keys())[0] ) ``` -------------------------------- ### Access PSR Type Mappings Source: https://context7.com/energieid/entsoe-py/llms.txt Access mappings for Production System Resource (PSR) types, such as Solar, Wind Onshore, and Nuclear. Uses predefined keys for lookup. ```python # PSR Type mappings for generation types print(PSRTYPE_MAPPINGS['B16']) # Solar print(PSRTYPE_MAPPINGS['B19']) # Wind Onshore print(PSRTYPE_MAPPINGS['B14']) # Nuclear ``` -------------------------------- ### Query Generation by Fuel Type Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves actual electricity generation aggregated by production type. Use `psr_type` to filter for specific fuel sources and `nett=True` for net generation. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Brussels') end = pd.Timestamp('20231202', tz='Europe/Brussels') # Query all generation types for Belgium generation = client.query_generation('BE', start=start, end=end) print(generation.columns.tolist()) # ['Biomass', 'Fossil Gas', 'Nuclear', 'Solar', 'Wind Onshore', ...] # Filter for specific PSR type (e.g., B16 for Solar) solar_gen = client.query_generation('BE', start=start, end=end, psr_type='B16') # Get net generation (generation minus consumption for storage) net_gen = client.query_generation('BE', start=start, end=end, nett=True) ``` -------------------------------- ### Download Single File Source: https://context7.com/energieid/entsoe-py/llms.txt Download a single file by its folder and filename from the ENTSO-E File Library. Returns a pandas DataFrame. ```python # Download a single file by name - returns DataFrame df = client.download_single_file( folder='AcceptedAggregatedOffers_17.1.D', filename=list(file_list.keys())[0] ) ``` -------------------------------- ### Download Multiple Files Source: https://context7.com/energieid/entsoe-py/llms.txt Download multiple files by their unique IDs from the ENTSO-E File Library. Returns a concatenated pandas DataFrame. ```python # Download multiple files by unique IDs - returns concatenated DataFrame file_ids = list(file_list.values())[:5] # First 5 files df_combined = client.download_multiple_files(file_ids) ``` -------------------------------- ### Custom API Request with Parameters Source: https://context7.com/energieid/entsoe-py/llms.txt Make custom API requests using the `_base_request` method for unsupported endpoints. Requires specifying parameters like document type and domain. ```python from entsoe import EntsoeRawClient import pandas as pd client = EntsoeRawClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Brussels') end = pd.Timestamp('20231202', tz='Europe/Brussels') # Custom request with document type and domain parameters params = { 'documentType': 'A44', # Price document 'in_Domain': '10YBE----------2', # Belgium EIC code 'out_Domain': '10YBE----------2' } response = client._base_request(params=params, start=start, end=end) print(response.text) ``` -------------------------------- ### Imbalance Volumes Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves system imbalance volumes. ```APIDOC ## query_imbalance_volumes - Imbalance Volumes ### Description Retrieves system imbalance volumes. ### Method `query_imbalance_volumes` ### Endpoint `/query_imbalance_volumes` ### Parameters #### Query Parameters - **country_code** (string) - Required - The country code for which to retrieve imbalance volumes (e.g., 'DE_LU'). - **start** (datetime) - Required - The start of the period. - **end** (datetime) - Required - The end of the period. - **include_resolution** (boolean) - Optional - Whether to include resolution information. ### Request Example ```python imbalance_vol = client.query_imbalance_volumes('DE_LU', start=start, end=end) imbalance_vol_res = client.query_imbalance_volumes( 'DE_LU', start=start, end=end, include_resolution=True ) ``` ### Response #### Success Response (200) - **imbalance_volumes** (DataFrame) - A pandas DataFrame containing system imbalance volumes. Can include resolution information if requested. ``` -------------------------------- ### Query Generation by Power Plant Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves actual generation data for individual power plants. Use `include_eic=True` to include EIC codes and `psr_type` to filter by generation type. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231215', tz='Europe/Brussels') end = pd.Timestamp('20231216', tz='Europe/Brussels') # Query per-plant generation for Belgium plant_gen = client.query_generation_per_plant('BE', start=start, end=end) # Include EIC codes in output plant_gen_eic = client.query_generation_per_plant( 'BE', start=start, end=end, include_eic=True ) # Filter by PSR type (e.g., B14 for Nuclear) nuclear_plants = client.query_generation_per_plant( 'BE', start=start, end=end, psr_type='B14' ) ``` -------------------------------- ### List Files in ENTSO-E Folder Source: https://github.com/energieid/entsoe-py/blob/master/README.md Use the list_folder method to retrieve a dictionary of filenames and their corresponding unique IDs from a specified folder in the ENTSO-E file library. ```python # this returns a dict of {filename: unique_id}: file_list = client.list_folder('AcceptedAggregatedOffers_17.1.D') ``` -------------------------------- ### Make Custom API Requests Source: https://github.com/energieid/entsoe-py/blob/master/README.md Allows making custom requests to the ENTSO-E API by defining parameters manually. This is useful for accessing data not covered by the client's predefined methods. The response text can be accessed directly. ```python params = { 'documentType': 'A44', 'in_Domain': '10YBE----------2', 'out_Domain': '10YBE----------2' } response = client._base_request(params=params, start=start, end=end) print(response.text) ``` -------------------------------- ### query_load_forecast - Day-Ahead Load Forecast Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves forecasted electricity load for a specified bidding zone. This method can be used in conjunction with `query_load` to compare forecasts with actual consumption. ```APIDOC ## POST /api/query_load_forecast ### Description Retrieves forecasted electricity load for a specified bidding zone. Returns a DataFrame with forecasted load values. ### Method POST (or GET, depending on client implementation) ### Endpoint N/A (Client-side abstraction of ENTSO-E REST API) ### Parameters #### Path Parameters None #### Query Parameters - **country_code** (string) - Required - The bidding zone code (e.g., 'DE_LU'). - **start** (pd.Timestamp) - Required - The start of the time range (timezone-aware). - **end** (pd.Timestamp) - Required - The end of the time range (timezone-aware). ### Request Example ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231210', tz='Europe/Berlin') end = pd.Timestamp('20231211', tz='Europe/Berlin') # Query day-ahead load forecast for Germany-Luxembourg forecast = client.query_load_forecast('DE_LU', start=start, end=end) # Compare with actual load actual = client.query_load('DE_LU', start=start, end=end) # Combine using utility function combined = client.query_load_and_forecast('DE_LU', start=start, end=end) print(combined.columns) # ['Forecasted Load', 'Actual Load'] ``` ### Response #### Success Response (200) - **Pandas DataFrame** - DataFrame with 'Forecasted Load' column, indexed by timestamp. ``` -------------------------------- ### Query Imbalance Volumes Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves system imbalance volumes for a specified country or region and time range. An option to include resolution information is available. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Berlin') end = pd.Timestamp('20231202', tz='Europe/Berlin') # Query imbalance volumes for Germany-Luxembourg imbalance_vol = client.query_imbalance_volumes('DE_LU', start=start, end=end) # Include resolution information imbalance_vol_res = client.query_imbalance_volumes( 'DE_LU', start=start, end=end, include_resolution=True ) ``` -------------------------------- ### Query Hydro Reservoir Levels Source: https://context7.com/energieid/entsoe-py/llms.txt Query aggregate water reservoirs and hydro storage levels for specific countries. Supports countries with significant hydro power generation. ```python hydro_storage = client.query_aggregate_water_reservoirs_and_hydro_storage( 'NO_1', start=start, end=end ) ``` ```python ch_hydro = client.query_aggregate_water_reservoirs_and_hydro_storage( 'CH', start=start, end=end ) ``` -------------------------------- ### Query Imbalance Settlement Prices Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves imbalance prices used for settlement in the balancing market for a specified country and time range. The output typically includes columns for positive and negative imbalance prices. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231201', tz='Europe/Brussels') end = pd.Timestamp('20231202', tz='Europe/Brussels') # Query imbalance prices for Belgium imbalance_prices = client.query_imbalance_prices('BE', start=start, end=end) print(imbalance_prices.columns.tolist()) ``` -------------------------------- ### Net Transfer Capacity (Week-ahead, Month-ahead, Year-ahead) Source: https://context7.com/energieid/entsoe-py/llms.txt Queries for Net Transfer Capacity (NTC) for different time horizons. ```APIDOC ## Net Transfer Capacity (NTC) ### Description Retrieves Net Transfer Capacity data for different time horizons (week-ahead, month-ahead, year-ahead) between two countries. ### Methods - `query_net_transfer_capacity_weekahead` - `query_net_transfer_capacity_monthahead` - `query_net_transfer_capacity_yearahead` ### Parameters - **country_code_from** (string) - Required - The code of the exporting country. - **country_code_to** (string) - Required - The code of the importing country. - **start** (datetime) - Required - The start of the period. - **end** (datetime) - Required - The end of the period. ### Request Example (Week-ahead) ```python ntc_wa = client.query_net_transfer_capacity_weekahead( country_code_from='BE', country_code_to='NL', start=start, end=end ) ``` ### Request Example (Month-ahead) ```python ntc_ma = client.query_net_transfer_capacity_monthahead('BE', 'NL', start, end) ``` ### Request Example (Year-ahead) ```python ntc_ya = client.query_net_transfer_capacity_yearahead('BE', 'NL', start, end) ``` ``` -------------------------------- ### Query Day-Ahead Scheduled Exchanges Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves commercial scheduled exchanges between bidding zones. Set `dayahead=True` for day-ahead schedules and `dayahead=False` for total scheduled exchanges including intraday adjustments. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231210', tz='Europe/Amsterdam') end = pd.Timestamp('20231211', tz='Europe/Amsterdam') # Day-ahead scheduled exchanges from Netherlands to Belgium scheduled = client.query_scheduled_exchanges( country_code_from='NL', country_code_to='BE', start=start, end=end, dayahead=True ) # Total scheduled exchanges (includes intraday adjustments) total_scheduled = client.query_scheduled_exchanges( country_code_from='NL', country_code_to='BE', start=start, end=end, dayahead=False ) ``` -------------------------------- ### query_day_ahead_prices - Day-Ahead Market Prices Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves Single Day-Ahead Coupling (SDAC) electricity prices for a specified bidding zone. The data is returned as a timezone-aware Pandas Series. ```APIDOC ## POST /api/query_day_ahead_prices ### Description Retrieves SDAC (Single Day-Ahead Coupling) electricity prices for a specified bidding zone. Returns hourly prices before October 2025, and 15-minute prices after. The result is a timezone-aware Pandas Series. ### Method POST (or GET, depending on client implementation) ### Endpoint N/A (Client-side abstraction of ENTSO-E REST API) ### Parameters #### Path Parameters None #### Query Parameters - **country_code** (string) - Required - The bidding zone code (e.g., 'BE', 'DE_LU'). - **start** (pd.Timestamp) - Required - The start of the time range (timezone-aware). - **end** (pd.Timestamp) - Required - The end of the time range (timezone-aware). - **process_type** (string) - Optional - The type of process (e.g., 'A65'). - **market_type** (string) - Optional - The type of market (e.g., 'A65'). ### Request Example ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20231215', tz='Europe/Amsterdam') end = pd.Timestamp('20231216', tz='Europe/Amsterdam') # Query for Netherlands prices = client.query_day_ahead_prices('NL', start=start, end=end) # Query for Germany-Luxembourg bidding zone prices_de = client.query_day_ahead_prices('DE_LU', start=start, end=end) # Result is a timezone-aware Pandas Series print(f"Average price: {prices.mean():.2f} EUR/MWh") print(f"Max price: {prices.max():.2f} EUR/MWh") print(f"Min price: {prices.min():.2f} EUR/MWh") ``` ### Response #### Success Response (200) - **Pandas Series** - Timezone-aware Series with prices (EUR/MWh) indexed by timestamp. ``` -------------------------------- ### Query Hydro Storage Data Source: https://context7.com/energieid/entsoe-py/llms.txt Retrieves aggregate filling rate of water reservoirs and hydro storage for a specified country and time range. ```python from entsoe import EntsoePandasClient import pandas as pd client = EntsoePandasClient(api_key='your-api-key') start = pd.Timestamp('20230101', tz='Europe/Oslo') end = pd.Timestamp('20231231', tz='Europe/Oslo') ```