Skip to main content

Async Python client for the Octopus Energy REST and GraphQL APIs

Project description

aiooctopusenergy

Async Python client for the Octopus Energy REST API.

Installation

pip install aiooctopusenergy

Usage

import aiohttp
from aiooctopusenergy import OctopusEnergyClient

async with aiohttp.ClientSession() as session:
    client = OctopusEnergyClient(api_key="sk_live_...", session=session)

    # Get account details
    account = await client.get_account("A-AAAA1111")
    for prop in account.properties:
        for meter in prop.electricity_meter_points:
            print(f"MPAN: {meter.mpan}, Export: {meter.is_export}")

    # Get half-hourly consumption
    readings = await client.get_electricity_consumption(
        mpan="1100009640372",
        serial_number="22L4344979",
    )
    for r in readings:
        print(f"{r.interval_start}: {r.consumption} kWh")

    # Get Agile rates (no auth required)
    rates = await client.get_electricity_rates(
        product_code="AGILE-24-10-01",
        tariff_code="E-1R-AGILE-24-10-01-C",
    )
    for rate in rates:
        print(f"{rate.valid_from}: {rate.value_inc_vat}p/kWh")

    # Look up Grid Supply Point
    gsps = await client.get_grid_supply_points("DE45")
    print(f"Region: {gsps[0].group_id}")

API Reference

OctopusEnergyClient(api_key, session=None)

  • get_account(account_number) — Account details with meters and tariff history
  • get_electricity_consumption(mpan, serial, *, period_from, period_to) — Half-hourly electricity readings
  • get_gas_consumption(mprn, serial, *, period_from, period_to) — Half-hourly gas readings
  • get_electricity_rates(product, tariff, *, period_from, period_to) — Electricity unit rates
  • get_electricity_standing_charges(product, tariff, *, period_from, period_to) — Electricity standing charges
  • get_gas_rates(product, tariff, *, period_from, period_to) — Gas unit rates
  • get_gas_standing_charges(product, tariff, *, period_from, period_to) — Gas standing charges
  • get_grid_supply_points(postcode) — GSP region lookup

Exceptions

  • OctopusEnergyError — Base exception
  • OctopusEnergyAuthenticationError — Invalid API key (HTTP 401)
  • OctopusEnergyNotFoundError — Resource not found (HTTP 404)
  • OctopusEnergyConnectionError — Network error
  • OctopusEnergyTimeoutError — Request timeout

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

aiooctopusenergy-0.4.3.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

aiooctopusenergy-0.4.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file aiooctopusenergy-0.4.3.tar.gz.

File metadata

  • Download URL: aiooctopusenergy-0.4.3.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for aiooctopusenergy-0.4.3.tar.gz
Algorithm Hash digest
SHA256 12c261a8c2324e5f42100a35d60a394cf035f20c0db62884f46ef9651a5906d1
MD5 29a532c5322c02ccf31040e2ba3d137f
BLAKE2b-256 e14c6874e9b63b88901404058804a70a3f51a4d9d2a1eff736b6360bd87bf938

See more details on using hashes here.

File details

Details for the file aiooctopusenergy-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for aiooctopusenergy-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0d4f8ccb073b03ad24e3b63dd8cf4b65c9775f5042cc4d4fad3a66b7cdd7c0a5
MD5 e298840240902bd147338d4f815529ae
BLAKE2b-256 0a492a6f31bcca4b5b263faba8c1bc945d001c5f4ec85cdc5c7bf54d4eb8bb11

See more details on using hashes here.

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