Asynchronous Python client providing energy/gas prices from easyEnergy
Project description
Asynchronous Python client for the easyEnergy price API.
About
A Python package for retrieving dynamic electricity and gas prices from easyEnergy. The package uses the current price-graph API and supports both hourly and quarter-hour electricity prices.
Installation
pip install easyenergy
To use the CLI as well:
pip install "easyenergy[cli]"
Data
[!NOTE] The bundled example scripts are plain Python usage examples. They intentionally use fixed request dates so you can test a known day; adjust those dates when you want to inspect another period.
You can read the following datasets with this package:
Electricity prices
[!IMPORTANT] The new easyEnergy price API exposes multiple electricity price components per interval. For electricity usage you can select either the market price (
price/priceIncVat) or the billed invoice price (invoicePrice). Return to grid is mapped to the VAT-inclusive return price field (priceIncVat).
[!TIP] A single
energy_prices(...)fetch exposes bothcurrent_market_priceandcurrent_invoice_price, plusmarket_pricesandinvoice_prices. That makes it straightforward to create separate Home Assistant price entities for the Energy dashboard without extra API calls.
Electricity prices can be requested per hour or per quarter. This package defaults to hourly data for backwards compatibility, but quarter prices are also supported through ElectricityGranularity.QUARTER.
Usage properties:
| Property | Type | Description |
|---|---|---|
current_price |
float | Current usage price for the active interval |
current_market_price |
float | Current market price (including VAT) |
current_market_price_excluding_vat |
float | Current market price (excluding VAT) |
current_invoice_price |
float | Current invoice/billed price |
average_price |
float | Average price over all intervals |
extreme_prices |
tuple | Minimum and maximum price (min, max) |
highest_price_time |
datetime | Timestamp of the highest price |
lowest_price_time |
datetime | Timestamp of the lowest price |
pct_of_max |
float | Current price as percentage of maximum |
periods_priced_equal_or_lower |
int | Number of intervals with current price or lower |
periods_priced_equal_or_higher |
int | Number of intervals with current price or higher |
prices |
dict | Usage price series (datetime → price) |
market_prices |
dict | Market prices including VAT |
market_prices_excluding_vat |
dict | Market prices excluding VAT |
invoice_prices |
dict | Invoice/billed prices |
Return properties:
| Property | Type | Description |
|---|---|---|
current_return_price |
float | Current return/feed-in price |
average_return_price |
float | Average return price |
extreme_return_prices |
tuple | Minimum and maximum return price |
highest_return_price_time |
datetime | Timestamp of highest return price |
lowest_return_price_time |
datetime | Timestamp of lowest return price |
pct_of_max_return |
float | Current return as percentage of maximum |
return_periods_priced_equal_or_higher |
int | Return intervals with current price or higher |
return_prices |
dict | Return price series (datetime → price) |
Interval data:
Full interval rows via energy.intervals, each containing: price, price_inc_vat, energy_tax, purchase_price, invoice_price, average, average_inc, unit, and granularity.
Gas prices
The gas prices are fixed per day in the new price API.
| Property | Type | Description |
|---|---|---|
current_price |
float | Current gas price |
average_price |
float | Average gas price |
extreme_prices |
tuple | Minimum and maximum price (min, max) |
highest_price_time |
datetime | Timestamp of the highest price |
lowest_price_time |
datetime | Timestamp of the lowest price |
prices |
dict | Gas price series (datetime → price) |
Full interval rows available via gas.intervals.
Example
import asyncio
from datetime import date
from easyenergy import (
EasyEnergy,
ElectricityGranularity,
VatOption,
)
async def main() -> None:
"""Fetch electricity and gas prices from easyEnergy."""
async with EasyEnergy(vat=VatOption.INCLUDE) as client:
start_date = date(2026, 4, 19)
end_date = date(2026, 4, 19)
energy = await client.energy_prices(
start_date,
end_date,
granularity=ElectricityGranularity.QUARTER,
)
gas = await client.gas_prices(start_date, end_date)
print(f"Quarter intervals: {len(energy.intervals)}")
print(f"Current market price: {energy.current_market_price}")
print(f"Current invoice price: {energy.current_invoice_price}")
print(f"Average price: {energy.average_price}")
print(f"Average return price: {energy.average_return_price}")
print(f"First electricity interval: {energy.intervals[0]}")
print(f"Average gas price: {gas.average_price}")
print(f"First gas interval: {gas.intervals[0]}")
if __name__ == "__main__":
asyncio.run(main())
Examples
The repository ships plain usage examples under examples/:
poetry run python ./examples/energy.py
poetry run python ./examples/gas.py
poetry run python ./examples/prices_list.py
Those files are intentionally simple and meant as package-usage references, not as a full CLI. Update the fixed request date constants in the files when you want to inspect another day.
CLI Tool
The package also ships a Rich/Typer-based CLI under src/easyenergy/cli:
poetry run easyenergy energy --date 2026-04-19
poetry run easyenergy energy --date 2026-04-19 --price-type invoice
poetry run easyenergy gas --start-date 2026-04-01 --end-date 2026-04-02
poetry run easyenergy prices-list --date 2026-04-19 --granularity quarter
poetry run easyenergy entities --date 2026-04-19
The entities command shows all available properties for Home Assistant integration, grouped by usage, return, and gas.
Useful CLI options:
--date YYYY-MM-DDfor a single day--start-date YYYY-MM-DD --end-date YYYY-MM-DDfor a range--vat include|excludeto switch between market prices with or without VAT--price-type market|invoiceto choose between market and billed electricity usage prices--granularity hour|quarterfor electricity commands--limit Nto limit the number of printed intervals; without it, all returned intervals are shown
Class Parameters
| Parameter | value Type | Description |
|---|---|---|
vat |
enum (default: VatOption.INCLUDE) | Include or exclude VAT on class level |
Function Parameters
| Parameter | value Type | Description |
|---|---|---|
start_date |
date | The start date of the selected period |
end_date |
date | The end date of the selected period |
vat |
enum (default: class value) | Include or exclude VAT (VatOption.INCLUDE or VatOption.EXCLUDE) |
granularity |
enum (electricity only) | Electricity granularity (ElectricityGranularity.HOUR or ElectricityGranularity.QUARTER) |
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyenergy-3.0.0.tar.gz.
File metadata
- Download URL: easyenergy-3.0.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcceeda7815a856d26dde17296346d64c3b6dce895fc081b3d7d1b3a6185ad98
|
|
| MD5 |
7d530c627fbf9f067eab62ff08fb8d8e
|
|
| BLAKE2b-256 |
bdf1152e5f56b814c596717ae45004bea76db143dcd4d1e7ca4ad9ea822450c6
|
Provenance
The following attestation bundles were made for easyenergy-3.0.0.tar.gz:
Publisher:
release.yaml on klaasnicolaas/python-easyenergy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyenergy-3.0.0.tar.gz -
Subject digest:
bcceeda7815a856d26dde17296346d64c3b6dce895fc081b3d7d1b3a6185ad98 - Sigstore transparency entry: 1383019057
- Sigstore integration time:
-
Permalink:
klaasnicolaas/python-easyenergy@809fbe796d9fb80a6bd77e53a57b4beb61cc5328 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/klaasnicolaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@809fbe796d9fb80a6bd77e53a57b4beb61cc5328 -
Trigger Event:
release
-
Statement type:
File details
Details for the file easyenergy-3.0.0-py3-none-any.whl.
File metadata
- Download URL: easyenergy-3.0.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cd8c7256d1c47d16afe882899db8033bfb8a7808a290408b8da0eab754c715d
|
|
| MD5 |
839cc700177f8883fadf1e63ac9c354d
|
|
| BLAKE2b-256 |
85cd00c54ad35b9ac56b0467b231245cbf9dc8804d6ef886f9eab43ac57d50b5
|
Provenance
The following attestation bundles were made for easyenergy-3.0.0-py3-none-any.whl:
Publisher:
release.yaml on klaasnicolaas/python-easyenergy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyenergy-3.0.0-py3-none-any.whl -
Subject digest:
4cd8c7256d1c47d16afe882899db8033bfb8a7808a290408b8da0eab754c715d - Sigstore transparency entry: 1383019192
- Sigstore integration time:
-
Permalink:
klaasnicolaas/python-easyenergy@809fbe796d9fb80a6bd77e53a57b4beb61cc5328 -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/klaasnicolaas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@809fbe796d9fb80a6bd77e53a57b4beb61cc5328 -
Trigger Event:
release
-
Statement type: