Use EntsoeRawClient to fetch raw data directly from the API. Some methods return XML strings, while others return ZIP files as bytes.
To perform a request not explicitly covered by a named method, you can use the private _base_request method by passing a dictionary of parameters.
from entsoe import EntsoeRawClient
import pandas as pd
client = EntsoeRawClient(api_key=<YOUR API KEY>)
start = pd.Timestamp('20171201', tz='Europe/Brussels')
end = pd.Timestamp('20180101', tz='Europe/Brussels')
country_code = 'BE'
# Example: Querying XML
xml_string = client.query_day_ahead_prices(country_code, start, end)
with open('outfile.xml', 'w') as f:
f.write(xml_string)
# Example: Querying ZIP bytes
zip_bytes = client.query_unavailability_of_generation_units(country_code, start, end)
with open('outfile.zip', 'wb') as f:
f.write(zip_bytes)
# Example: Custom request using _base_request
params = {
'documentType': 'A44',
'in_Domain': '10YBE----------2',
'out_Domain': '10YBE----------2'
}
response = client._base_request(params=params, start=start, end=end)
print(response.text)