uk-energy (Python)
Typed Python clients for the UK's public electricity data APIs. Mirrors the TypeScript packages in the same repo.
pip install uk-energy
Contains BMRS data © Elexon Limited copyright and database right 2026. Contains NESO Data Portal data, used under the NESO Open Data Licence. Carbon Intensity data © National Energy System Operator, CC BY 4.0.
See the repo README for the full attribution and licence notes.
Packages
| Module | Covers | Status |
|---|---|---|
uk_energy.core |
HttpClient / AsyncHttpClient on httpx: retries with jittered backoff, per-host rate limiting, pagination, pluggable cache, FixtureTransport for tests |
built, unpublished |
uk_energy.carbon_intensity |
Carbon Intensity API: CarbonIntensityClient / AsyncCarbonIntensityClient — national and regional intensity, forecasts, generation mix |
published |
uk_energy.elexon |
Elexon Insights (BMRS): ElexonClient / AsyncElexonClient — BOALF, BOD, FUELINST, physical notifications, BMU reference, system prices |
built, unpublished |
uk_energy.neso |
NESO Data Portal | planned |
from uk_energy.elexon import ElexonClient
ex = ElexonClient()
boalf = ex.datasets_boalf("2026-10-15T00:00Z", "2026-10-15T01:00Z") # 1,650 rows, every unit
curtailed = [r for r in boalf if r["soFlag"]]
wind = [u for u in ex.reference_bm_units() if u["fuelType"] == "WIND"] # 287 units
ex.balancing_system_prices("2026-10-15", 1)[0]["systemSellPrice"] # 174.23
ex.datasets_fuelinst(publish_from="2026-10-15T00:00Z", publish_to="2026-10-15T00:30Z")
ex.datasets_stream("MELS", from_="2026-10-15T00:00Z", to="2026-10-15T01:00Z") # any /stream dataset
# every WIND unit: the reference list + 3 requests per 200 units
day = ex.curtailment_for_day("2026-10-15")
total = day["total"] # curtailedMwh, soFlaggedMwh, cashflowGbp, units, acceptances
worst = day["units"][0] # most-curtailed unit; day["periods"] has one row per unit per period
Settlement time is local (Europe/London): uk_energy.core.settlement_period_at(dt) gives the
settlement date and period for an instant; settlement_period_start(date, sp) inverts it.
from uk_energy.carbon_intensity import CarbonIntensityClient
ci = CarbonIntensityClient()
ci.intensity_current()["intensity"] # {"forecast": 125, "actual": 134, "index": "moderate"}
ci.regional_for_postcode("M1")["data"][0] # region 3, North West England
ci.intensity_forward48h("2026-10-15T00:00Z") # 97 half-hour periods
Note: intensity_for_date() uses a local GB day (BST in summer), and range endpoints include
the period containing from_; see the TypeScript package README for the full list.
Development
cd python
uv sync
uv run pytest # fixtures only, no network
UK_ENERGY_LIVE=1 uv run pytest -m live
uv run ruff check . && uv run mypy
Metadata
Release files for uk-energy 0.2.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 | Provenance | |
|---|---|---|---|---|
| uk_energy-0.2.0.tar.gz | 78.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uk_energy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 112.7 kB
Release files / uk_energy-0.2.0.tar.gz
| Download URL | uk_energy-0.2.0.tar.gz |
|---|---|
| Size | 78.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
badab8b1ac43ceee01412e412bcf393bcf57b4717baf0bcda175efdb2677d081
|
|
BLAKE2b-256 checksum How to use checksums |
22b56c3169c5659267c03cecec1852c7148cd2929fd2c1edbb689fd906c2bfe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 22, 2026.
Transparency logRelease files / uk_energy-0.2.0-py3-none-any.whl
| Download URL | uk_energy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a1c1eedf6bf30e78c57d448ef7825c2dab23cf28c6d5267c186669414672af1
|
|
BLAKE2b-256 checksum How to use checksums |
b2823e0bce8dad4ab0654fdbbd08cdba1adc8f5bc3c3790879dc51ec0f37eb2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 22, 2026.
Transparency logSecurity for uk-energy 0.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for uk_energy-0.2.0.tar.gz
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 Oct 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.