Async Python client for the UK Carbon Intensity API
Project description
aioukcarbon
Async Python client for the UK Carbon Intensity API.
Data provided by National Energy System Operator (NESO) via the Carbon Intensity API.
Installation
pip install aioukcarbon
Usage
import asyncio
from aioukcarbon import CarbonIntensityClient
async def main():
async with CarbonIntensityClient() as client:
# Regional intensity by postcode
regional = await client.get_regional_intensity("DE45")
print(f"Region: {regional.shortname}")
print(f"Forecast: {regional.periods[0].intensity.forecast} gCO2eq/kWh")
print(f"Index: {regional.periods[0].intensity.index}")
# National intensity
national = await client.get_national_intensity()
print(f"National: {national.intensity.forecast} gCO2eq/kWh")
# Generation mix
mix = await client.get_generation_mix()
for fuel in mix.generationmix:
print(f" {fuel.fuel}: {fuel.perc}%")
# 24h regional forecast
forecast = await client.get_regional_forecast("DE45")
for period in forecast.periods:
print(f" {period.from_time}: {period.intensity.forecast} gCO2eq/kWh")
asyncio.run(main())
API Reference
CarbonIntensityClient
get_regional_intensity(postcode)- Current regional carbon intensityget_regional_forecast(postcode, hours=24)- Regional forecast (24h or 48h)get_national_intensity()- Current national carbon intensityget_generation_mix()- Current national generation mix
Exceptions
CarbonIntensityError- Base exceptionCarbonIntensityConnectionError- Connection failuresCarbonIntensityTimeoutError- Request timeoutsCarbonIntensityNoDataError- No data available for postcode
License
MIT
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 aioukcarbon-0.2.0.tar.gz.
File metadata
- Download URL: aioukcarbon-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71019584e5daaad0d0e5d0f911a129aa9f90a0b92a5eab00c24411aede882211
|
|
| MD5 |
2316a20f2db62c09ee9c2720ad952ef5
|
|
| BLAKE2b-256 |
dd28f69d4ab773953ce19821a434cfa73779c6a0ba7e984aff18f4ed03ba2c61
|
Provenance
The following attestation bundles were made for aioukcarbon-0.2.0.tar.gz:
Publisher:
ci.yml on darrylcauldwell/aioukcarbon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioukcarbon-0.2.0.tar.gz -
Subject digest:
71019584e5daaad0d0e5d0f911a129aa9f90a0b92a5eab00c24411aede882211 - Sigstore transparency entry: 1041564311
- Sigstore integration time:
-
Permalink:
darrylcauldwell/aioukcarbon@683dd5b7b283046ea1b728b1bcf43c462c60f47c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/darrylcauldwell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@683dd5b7b283046ea1b728b1bcf43c462c60f47c -
Trigger Event:
push
-
Statement type:
File details
Details for the file aioukcarbon-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aioukcarbon-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92d846db68703616ee731a83730452e4b3f739c176f5ee893b2294e263a3f813
|
|
| MD5 |
7f8d6c2ca8e652e2991e83902b91e331
|
|
| BLAKE2b-256 |
7a645a22e7b6460874aba030c670cdb93bd9f1b91cb049c14365e83f9641439e
|
Provenance
The following attestation bundles were made for aioukcarbon-0.2.0-py3-none-any.whl:
Publisher:
ci.yml on darrylcauldwell/aioukcarbon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioukcarbon-0.2.0-py3-none-any.whl -
Subject digest:
92d846db68703616ee731a83730452e4b3f739c176f5ee893b2294e263a3f813 - Sigstore transparency entry: 1041564377
- Sigstore integration time:
-
Permalink:
darrylcauldwell/aioukcarbon@683dd5b7b283046ea1b728b1bcf43c462c60f47c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/darrylcauldwell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@683dd5b7b283046ea1b728b1bcf43c462c60f47c -
Trigger Event:
push
-
Statement type: