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.1.0.tar.gz (6.5 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.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file aioukcarbon-0.1.0.tar.gz.

File metadata

  • Download URL: aioukcarbon-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aioukcarbon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8bf124f2c4f5b6fc6d1e9f1631f1130e8d5fb8c7a1d92dec0c6c41f11bda0897
MD5 2c1cd2ec9f8f4692839b524a32672686
BLAKE2b-256 18d790143542dd24d2f5c8cb9c7d60c167055fd44f08fe53c3898cfc1bd79f18

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioukcarbon-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: aioukcarbon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4023f4125aef7cabd6b365e4086215f477378f130a4e34b2b893cfb7b0bbc6a
MD5 9e3a6a71b757400e56ec92c45d724c9b
BLAKE2b-256 00795eaf43a9c340113ebc1a7c962d1d2b63b81b0ab8736b831c4a0a52498801

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioukcarbon-0.1.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