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 energyzeroimport asyncio
from datetime import date
from energyzero import EnergyZero
async def main() -> None:
"""Show example on fetching the energy prices from EnergyZero."""
async with EnergyZero() 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 specificdatetimetimestamp_pricesβ List of hourly price entries:- REST:
{"timestamp": datetime, "price": float} - GraphQL:
{"timerange": TimeRange, "price": float}
- REST:
highest_price_time_rangeβTimeRangewhere the price is highestlowest_price_time_rangeβTimeRangewhere 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 specificdatetimetimestamp_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 |
|---|---|---|
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. |
| 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. |
| Parameter | Type | Description |
|---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
interval |
Interval |
Data interval (see Interval enum values). |
vat |
VatOption | None |
VAT inclusion (included by default). |
| Parameter | Type | Description |
|---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
interval |
Interval |
Data interval (see Interval enum values). |
vat |
VatOption | None |
VAT inclusion (included by default). |
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
Specifies the interval for prices returned by the legacy methods.
| Value | Description |
|---|---|
DAY = 4 |
Daily prices |
MONTH = 5 |
Monthly prices |
YEAR = 6 |
Yearly prices |
WEEK = 9 |
Weekly prices |
Used in: get_electricity_prices_legacy, get_gas_prices_legacy
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.12+
- Poetry
Install all packages, including all development requirements:
poetry installPoetry creates by default an virtual environment where it installs all necessary pip packages.
This repository uses the prek framework, all changes are linted and tested with each commit. To setup the prek check, run:
poetry run prek installAnd to run all checks and tests manually, use the following command:
poetry run prek run --all-filesIt uses pytest as the test framework. To run the tests:
poetry run pytestTo update the syrupy snapshot tests:
poetry run pytest --snapshot-updateMIT 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.
