Skip to main content

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 intensity
  • get_regional_forecast(postcode, hours=24) - Regional forecast (24h or 48h)
  • get_national_intensity() - Current national carbon intensity
  • get_generation_mix() - Current national generation mix

Exceptions

  • CarbonIntensityError - Base exception
  • CarbonIntensityConnectionError - Connection failures
  • CarbonIntensityTimeoutError - Request timeouts
  • CarbonIntensityNoDataError - No data available for postcode

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioukcarbon-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioukcarbon-0.2.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for aioukcarbon-0.2.0.tar.gz
Algorithm Hash digest
SHA256 71019584e5daaad0d0e5d0f911a129aa9f90a0b92a5eab00c24411aede882211
MD5 2316a20f2db62c09ee9c2720ad952ef5
BLAKE2b-256 dd28f69d4ab773953ce19821a434cfa73779c6a0ba7e984aff18f4ed03ba2c61

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioukcarbon-0.2.0.tar.gz:

Publisher: ci.yml on darrylcauldwell/aioukcarbon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for aioukcarbon-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92d846db68703616ee731a83730452e4b3f739c176f5ee893b2294e263a3f813
MD5 7f8d6c2ca8e652e2991e83902b91e331
BLAKE2b-256 7a645a22e7b6460874aba030c670cdb93bd9f1b91cb049c14365e83f9641439e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioukcarbon-0.2.0-py3-none-any.whl:

Publisher: ci.yml on darrylcauldwell/aioukcarbon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page