Asynchronous Python client for the EnergyZero API.
About
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:
Installation
pip install energyzero
Example
import asyncio
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
from energyzero import EnergyZero, Interval, PriceType
async def main() -> None:
"""Fetch today/tomorrow energy prices using the REST backend (default)."""
async with EnergyZero() as client:
local_tz = ZoneInfo("Europe/Amsterdam")
today = datetime.now(local_tz).date()
tomorrow = today + timedelta(days=1)
electricity_today = await client.get_electricity_prices(
start_date=today,
interval=Interval.QUARTER,
price_type=PriceType.ALL_IN,
local_tz=local_tz,
)
gas_today = await client.get_gas_prices(
start_date=today,
price_type=PriceType.ALL_IN,
local_tz=local_tz,
)
# Loop over additional days as needed
electricity_tomorrow = await client.get_electricity_prices(
start_date=tomorrow,
interval=Interval.QUARTER,
price_type=PriceType.MARKET_WITH_VAT,
local_tz=local_tz,
)
gas_tomorrow = await client.get_gas_prices(
start_date=tomorrow,
price_type=PriceType.MARKET,
local_tz=local_tz,
)
print(electricity_today.average_price, gas_today.current_price)
print(electricity_tomorrow.average_price, gas_tomorrow.current_price)
if __name__ == "__main__":
asyncio.run(main())
More examples can be found in the examples folder.
examples/graphql/*targets the GraphQL backend (multi-day ranges).examples/rest/electricity.pyshows quarter-hour electricity data.examples/rest/electricity_hourly.pyshows hourly electricity data.examples/rest/gas.pyandexamples/rest/prices_list.pyshow gas and combined list usage.
Data
[!NOTE] Currently tested primarily with day-ahead pricing (today/tomorrow).
You can retrieve both electricity and gas pricing data using this package. With v5.0 we support two official backends:
REST (default)
APIBackend.REST— Public REST API.- Electricity: hourly + quarter-hour. Gas: daily.
- Single date per call;
end_datemust equalstart_dateif provided. - The API may return a wider window, but the client now filters it to the requested local day.
GraphQL (optional)
APIBackend.GRAPHQL— GraphQL endpoint with multi-day ranges and extended metadata (TimeRange, averages).end_dateis required; electricity is always hourly (intervalis ignored).
⚡ Electricity Prices
Electricity prices change every hour. Prices for the next day are typically published between 14:00–15:00. Returned electricity prices are expressed in EUR/kWh.
Common fields (EnergyPrices)
current_price— Current electricity price for the active hour/time rangeaverage_price— Average price over the selected periodextreme_prices— Tuple(min_price, max_price)pct_of_max_price— Current price expressed as % of the maximumprice_at_time(moment)— Look up the price for a specific UTC timestamptimestamp_prices— List of{"timerange": TimeRange, "price": float}entrieshighest_price_time_range/lowest_price_time_range— TimeRange with highest/lowest pricetime_ranges_priced_equal_or_lower— Number of ranges priced ≤ current price
🔥 Gas Prices
Gas prices are fixed for 24 hours, and a new daily rate applies starting at 06:00 each morning. Returned gas prices are expressed in EUR/m³.
Common fields (EnergyPrices)
current_price— Current gas price for todayaverage_price— Average price over the requested periodextreme_prices— Tuple(min_price, max_price)price_at_time(moment)— Price lookup for a UTC timestamptimestamp_prices—{"timerange": TimeRange, "price": float}entrieshighest_price_time_range/lowest_price_time_range— TimeRange with highest/lowest pricepct_of_max_price,time_ranges_priced_equal_or_lower— Not applicable for gas prices
Client Methods (REST + GraphQL)
get_electricity_prices()
Returns electricity prices in EUR/kWh.
| Parameter | Type | Description |
|---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
interval |
Interval |
REST only: Interval.QUARTER or Interval.HOUR. Ignored by GraphQL. |
price_type |
PriceType or Iterable[PriceType] |
One or more price types to return (default ALL_IN). |
local_tz |
tzinfo |
Optional explicit timezone used to interpret the requested local date range on REST. |
get_gas_prices()
Returns gas prices in EUR/m³.
| Parameter | Type | Description |
|---|---|---|
start_date |
date |
Start of the period (local timezone). |
end_date |
date |
End of the period (local timezone). |
price_type |
PriceType or Iterable[PriceType] |
One or more price types to return (default ALL_IN). |
local_tz |
tzinfo |
Optional explicit timezone used to interpret the requested local date range on REST. |
Retrieving multiple price types
Retrieve multiple price types with one HTTP request per method call, on either
backend. Pass an iterable of PriceType values to the existing price_type parameter
of get_electricity_prices() or get_gas_prices(). This returns
dict[PriceType, EnergyPrices], even when the iterable contains only one type.
Passing a single PriceType still returns one EnergyPrices object. Type
overloads infer the return type from the input.
prices = await client.get_electricity_prices(
start_date=today,
interval=Interval.QUARTER,
price_type=(PriceType.MARKET_WITH_VAT, PriceType.ALL_IN),
local_tz=local_tz,
)
market_prices = prices[PriceType.MARKET_WITH_VAT]
all_in_prices = prices[PriceType.ALL_IN]
gas_prices = await client.get_gas_prices(
start_date=today,
price_type=(PriceType.MARKET_WITH_VAT, PriceType.ALL_IN),
local_tz=local_tz,
)
Duplicate types appear once, in first-requested order. An empty iterable raises
ValueError without making a request. Values must be PriceType members; raw
strings and other invalid values raise TypeError before making a request. REST filters each requested stream to the
local date and raises EnergyZeroNoDataError if a requested stream has no prices
for that date; no partial mapping is returned. GraphQL requires end_date and
retains its existing date-range behavior. Omitting price_type still returns
one EnergyPrices object using PriceType.ALL_IN.
PriceType
Specifies the type of prices returned by both backends.
| Value | Description |
|---|---|
MARKET |
Wholesale market price excluding VAT and without additional surcharges (REST base, GraphQL energyPriceExcl) |
MARKET_WITH_VAT |
Market price including VAT but still without surcharges (REST base_with_vat, GraphQL energyPriceIncl) |
ALL_IN_EXCL_VAT |
Market price plus surcharges excluding VAT (REST all_in, GraphQL energyPriceExcl + additionalCosts.priceExcl) |
ALL_IN |
Final consumer rate including VAT and surcharges (REST all_in_with_vat, GraphQL energyPriceIncl + additionalCosts.priceIncl). |
Used in: get_electricity_prices, get_gas_prices
Interval
Specifies the interval for REST API requests:
| Value | Description |
|---|---|
Interval.QUARTER |
15-minute electricity prices |
Interval.HOUR |
Hourly electricity prices |
Interval.DAY |
Daily gas prices |
Note: Interval is used by get_electricity_prices(). Gas prices are retrieved
through get_gas_prices() and use daily intervals internally on the REST API.
Contributing
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! :heart_eyes:
Setting up development environment
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
Installation
Install all packages, including all development requirements:
poetry install
Poetry creates by default an virtual environment where it installs all necessary pip packages.
Prek
This repository uses the prek framework, all changes are linted and tested with each commit. To setup the prek check, run:
poetry run prek install
And to run all checks and tests manually, use the following command:
poetry run prek run --all-files
Testing
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
License
MIT License
Copyright (c) 2022-2026 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.
Release files for energyzero 5.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| energyzero-5.1.0.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| energyzero-5.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.3 kB
Release files / energyzero-5.1.0.tar.gz
| Download URL | energyzero-5.1.0.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c525b3b51fe0626004ae7ee8a024eef496537c513dcc4b5c6ecb7d3401e53396
|
|
BLAKE2b-256 checksum How to use checksums |
9898b880ff38dc624844918dee51bb264bcc3f6cc56e3582cd7d7f1a68c2a6ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / energyzero-5.1.0-py3-none-any.whl
| Download URL | energyzero-5.1.0-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1601bb8844f6a8d5f41eba7531c662e6babff7e50f151b1e8a0935bc2e6f68e
|
|
BLAKE2b-256 checksum How to use checksums |
01852aeaa29fdc736d2ef7801e1f5966e0af52db1fadd5bbac99ca558eea3aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log