Asynchronous Python client for the EnergyZero API.
A python package with which you can retrieve the dynamic energy/gas prices from EnergyZero and can therefore also be used for third parties who purchase their energy via EnergyZero, such as:
pip install energyzero
import asyncio
from datetime import date
from energyzero import EnergyZero, VatOption
async def main() -> None:
"""Show example on fetching the energy prices from EnergyZero."""
async with EnergyZero(vat=VatOption.INCLUDE) as client:
start_date = date(2022, 12, 7)
end_date = date(2022, 12, 7)
energy = await client.get_electricity_prices(start_date, end_date)
gas = await client.get_gas_prices(start_date, end_date)
if __name__ == "__main__":
asyncio.run(main())
More examples can be found in the examples folder.
Note: Currently tested primarily with day-ahead pricing (today/tomorrow).
You can retrieve both electricity and gas pricing data using this package. Each data type supports a set of common fields, with some additional properties depending on whether you use the GraphQL or legacy REST endpoint.
Electricity prices change every hour. Prices for the next day are typically published between 14:00β15:00.
current_price
β Current electricity price for the current hour or time rangeaverage_price
β Average price over the selected periodextreme_prices
β Tuple of(min_price, max_price)
pct_of_max_price
β Current price as a percentage of the maximumprice_at_time(moment)
β Get price for a specificdatetime
timestamp_prices
β List of hourly price entries:- REST:
{"timestamp": datetime, "price": float}
- GraphQL:
{"timerange": TimeRange, "price": float}
- REST:
highest_price_time_range
βTimeRange
where the price is highestlowest_price_time_range
βTimeRange
where the price is lowesttime_ranges_priced_equal_or_lower
β Count of hours where the price is less than or equal to the current
highest_price_time
β Timestamp of the highest hourly pricelowest_price_time
β Timestamp of the lowest hourly pricehours_priced_equal_or_lower
β Count of hours with a price β€ current price
Gas prices are fixed for 24 hours, and a new daily rate applies starting at 06:00 each morning.
current_price
β Current gas price for todayaverage_price
β Average gas price over the selected periodextreme_prices
β Tuple of(min_price, max_price)
price_at_time(moment)
β Get price for a specificdatetime
timestamp_prices
β List of daily price entries:- REST:
{"timestamp": datetime, "price": float}
- GraphQL:
{"timerange": TimeRange, "price": float}
- REST:
highest_price_time_range
β Time range with the highest daily pricelowest_price_time_range
β Time range with the lowest daily pricepct_of_max_price
β Current price as a percentage of the maximumtime_ranges_priced_equal_or_lower
β Count of days with a price β€ current price
Parameter | Type | Description | Used by |
---|---|---|---|
vat |
VatOption (default: INCLUDE ) |
Include or exclude VAT at class level. | get_electricity_prices_legacy , get_gas_prices_legacy |
Value | Meaning |
---|---|
4 |
Day |
5 |
Month |
6 |
Year |
9 |
Week |
Parameter | Type | Description |
---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
price_type |
PriceType |
Type of price to return: ALL_IN or MARKET . |
β οΈ This method does not use the class-levelvat
setting.
Parameter | Type | Description |
---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
price_type |
PriceType |
Type of price to return: ALL_IN or MARKET . |
β οΈ This method does not use the class-levelvat
setting.
Parameter | Type | Description |
---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
interval |
int |
Data interval (see interval values table). |
vat |
VatOption | None |
VAT inclusion (fallback to class setting if None ). |
Parameter | Type | Description |
---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
interval |
int |
Data interval (see interval values table). |
vat |
VatOption | None |
VAT inclusion (fallback to class setting if None ). |
Defines whether prices returned by legacy methods should include VAT.
Value | Description |
---|---|
INCLUDE |
Return prices including VAT |
EXCLUDE |
Return prices excluding VAT |
Used in: get_electricity_prices_legacy
, get_gas_prices_legacy
π Ignored in GraphQL methods (
get_electricity_prices
,get_gas_prices
)
Specifies the type of prices returned by GraphQL methods.
Value | Description |
---|---|
MARKET |
Raw wholesale market price (excludes tax, VAT, and purchasing costs) |
ALL_IN |
Final consumer price (includes energy tax, VAT, and purchase fees) |
Used in: get_electricity_prices
, get_gas_prices
This is an active open-source project. We are always open to people who want to use the code or contribute to it.
We've set up a separate document for our contribution guidelines.
Thank you for being involved! π
The simplest way to begin is by utilizing the Dev Container feature of Visual Studio Code or by opening a CodeSpace directly on GitHub. By clicking the button below you immediately start a Dev Container in Visual Studio Code.
This Python project relies on Poetry as its dependency manager, providing comprehensive management and control over project dependencies.
You need at least:
- Python 3.11+
- Poetry
Install all packages, including all development requirements:
poetry install
Poetry creates by default an virtual environment where it installs all necessary pip packages.
This repository uses the pre-commit framework, all changes are linted and tested with each commit. To setup the pre-commit check, run:
poetry run pre-commit install
And to run all checks and tests manually, use the following command:
poetry run pre-commit run --all-files
It uses pytest as the test framework. To run the tests:
poetry run pytest
To update the syrupy snapshot tests:
poetry run pytest --snapshot-update
MIT License
Copyright (c) 2022-2025 Klaas Schoute
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.