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 historyget_electricity_consumption(mpan, serial, *, period_from, period_to)— Half-hourly electricity readingsget_gas_consumption(mprn, serial, *, period_from, period_to)— Half-hourly gas readingsget_electricity_rates(product, tariff, *, period_from, period_to)— Electricity unit ratesget_electricity_standing_charges(product, tariff, *, period_from, period_to)— Electricity standing chargesget_gas_rates(product, tariff, *, period_from, period_to)— Gas unit ratesget_gas_standing_charges(product, tariff, *, period_from, period_to)— Gas standing chargesget_grid_supply_points(postcode)— GSP region lookup
Exceptions
OctopusEnergyError— Base exceptionOctopusEnergyAuthenticationError— Invalid API key (HTTP 401)OctopusEnergyNotFoundError— Resource not found (HTTP 404)OctopusEnergyConnectionError— Network errorOctopusEnergyTimeoutError— 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.1.tar.gz
(19.3 kB
view details)
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 aiooctopusenergy-0.4.1.tar.gz.
File metadata
- Download URL: aiooctopusenergy-0.4.1.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
468c28d1a295b970534990f08fb47eba7b5ec23f8027d655bf0c87ee0ec56cf3
|
|
| MD5 |
69db36d9222989118a11986b3d2256bb
|
|
| BLAKE2b-256 |
69af33333e740be7e410a980c8bbf824adc2001ccfaa900b14dd9a476f93936d
|
File details
Details for the file aiooctopusenergy-0.4.1-py3-none-any.whl.
File metadata
- Download URL: aiooctopusenergy-0.4.1-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
699622f79aa222096b9822f4d0801505c941d1261e01528710f5db08aa518b66
|
|
| MD5 |
e34f87bba2e8809849a1c0969bbaa1d3
|
|
| BLAKE2b-256 |
6f3d5deeaff04d3180ac64d61fdc9b820c153cb6b0f105bdc806ac843039065b
|