Modern async Python client for the Octopus Energy GraphQL API
Project description
🐙 open-octopus
An Octopus Energy API client built for AI.
pip install open-octopus
Features · Quick Start · CLI · AI Agent · API Reference
Features
⚡ Live PowerReal-time consumption from Home Mini. See exactly what you're using right now. Updates every 10-30 seconds. Calculate cost per hour at current rates. |
🔌 Smart ChargingIntelligent Octopus dispatch slots. Know when your EV is charging. See upcoming charge windows. Never miss off-peak rates again. |
🎁 Saving SessionsFree electricity events. Get notified about upcoming free power events. Track rewards in Octopoints. Never miss free energy. |
🔥 Dual FuelElectricity + gas support. Track both meters. Get consumption history. See tariff details for gas and electric. |
🤖 AI AgentAsk questions in plain English. "What's my current rate?" "How much did I use yesterday?" Powered by Claude. |
🖥️ Menu BarmacOS status bar app. Live power, current rate, charging status, and balance. Always visible. One click away. |
Quick Start
⚡ Basic Usageimport asyncio
from open_octopus import OctopusClient
async def main():
async with OctopusClient(
api_key="sk_live_xxx",
account="A-XXXXXXXX"
) as client:
# Account balance
account = await client.get_account()
print(f"Balance: £{account.balance:.2f}")
# Current rate
tariff = await client.get_tariff()
rate = client.get_current_rate(tariff)
print(f"Rate: {rate.rate}p/kWh")
# Live power (Home Mini)
power = await client.get_live_power()
if power:
print(f"Power: {power.demand_kw:.2f} kW")
asyncio.run(main())
|
🔥 With Gasasync with OctopusClient(
api_key="sk_live_xxx",
account="A-XXXXXXXX",
gas_mprn="1234567890",
gas_meter_serial="G4A12345"
) as client:
# Gas consumption
gas = await client.get_daily_gas_usage(days=7)
for date, kwh in gas.items():
print(f"{date}: {kwh:.1f} kWh")
# Gas tariff
tariff = await client.get_gas_tariff()
print(f"Rate: {tariff.unit_rate}p/kWh")
|
💻 CLI
octopus status # Full overview
octopus rate # Current rate (off-peak/peak)
octopus power # Live consumption
octopus dispatch # Charging windows
octopus usage # Electricity usage
octopus gas # Gas usage
octopus sessions # Saving sessions
octopus watch # Live monitoring
🤖 AI Agent
Ask questions about your energy in plain English.
pip install 'open-octopus[agent]'
export ANTHROPIC_API_KEY="sk-ant-xxx"
octopus-ask "What's my current rate?"
octopus-ask "How much gas did I use this week?"
octopus-ask "When is my next charging window?"
octopus-ask "Am I on off-peak rates right now?"
Or use in Python:
from open_octopus import OctopusAgent
agent = OctopusAgent()
response = await agent.ask("What's my balance?")
print(response)
🖥️ Menu Bar (macOS)
pip install 'open-octopus[menubar]'
octopus-menubar
| ⚡ Live Power Real-time kW |
🌙 Rate Status Off-peak/peak |
🔌 Charging EV dispatch |
💰 Balance Account credit |
📚 API Reference
|
Account & Billing get_account() # Balance, status, address
get_tariff() # Electricity tariff
get_gas_tariff() # Gas tariff
get_current_rate() # Current rate + off-peak
|
Consumption get_consumption() # Half-hourly readings
get_daily_usage() # Daily totals
get_gas_consumption() # Gas readings
get_daily_gas_usage() # Daily gas totals
|
|
Smart Features get_live_power() # Real-time watts
get_dispatches() # Charge windows
get_dispatch_status() # Currently charging?
get_saving_sessions() # Free power events
|
Models Account # Balance, name, status
Tariff / GasTariff # Rates, standing charge
Rate # Current rate, period
Dispatch # Charge window
LivePower # Real-time demand
SavingSession # Free power event
|
⚙️ Configuration
Environment Variables
# Required
OCTOPUS_API_KEY=sk_live_xxx
OCTOPUS_ACCOUNT=A-XXXXXXXX
# Electricity meter (optional)
OCTOPUS_MPAN=1234567890123
OCTOPUS_METER_SERIAL=12A3456789
# Gas meter (optional)
OCTOPUS_GAS_MPRN=1234567890
OCTOPUS_GAS_METER_SERIAL=G4A12345
# AI agent (optional)
ANTHROPIC_API_KEY=sk-ant-xxx
Getting Your API Key
- Log in to Octopus Energy
- Go to Developer Settings
- Copy your API key (starts with
sk_live_)
Finding Your MPAN/MPRN
Your MPAN (electricity) and MPRN (gas) are on your energy bills.
Or discover them via the API:
account = await client.get_account()
print(account) # Includes meter info
How It Works
┌────────────────────────────────────────────────────────────────┐
│ Octopus Energy GraphQL API (Kraken) │
│ ↓ │
│ open-octopus async client │
│ • Account balance, tariffs │
│ • Consumption data (electricity + gas) │
│ • Intelligent Octopus dispatches │
│ • Live power (Home Mini telemetry) │
│ • Saving Sessions │
│ ↓ │
│ Your choice of interface │
│ • Python library (async/await) │
│ • CLI tool (octopus) │
│ • AI agent (octopus-ask) │
│ • Menu bar app (octopus-menubar) │
└────────────────────────────────────────────────────────────────┘
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 open_octopus-0.3.0.tar.gz.
File metadata
- Download URL: open_octopus-0.3.0.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04b9de01fa37e6656ba78d29fde54389500ade892c3535125b6cdb8033f3445b
|
|
| MD5 |
5c606e30f5bbaf2e99f3f3261c755b80
|
|
| BLAKE2b-256 |
0a67f30547a0278c17362dce17f0dda2e966dc6c58f947c0c3e05515780bc391
|
Provenance
The following attestation bundles were made for open_octopus-0.3.0.tar.gz:
Publisher:
publish.yml on abracadabra50/open-octopus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_octopus-0.3.0.tar.gz -
Subject digest:
04b9de01fa37e6656ba78d29fde54389500ade892c3535125b6cdb8033f3445b - Sigstore transparency entry: 781160193
- Sigstore integration time:
-
Permalink:
abracadabra50/open-octopus@e811e7bae561a48de7f6c10fb6987a28d3468318 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/abracadabra50
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e811e7bae561a48de7f6c10fb6987a28d3468318 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file open_octopus-0.3.0-py3-none-any.whl.
File metadata
- Download URL: open_octopus-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.4 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 |
2f17dc9b05bbb46e15eee34746d97e3a7c9bbee7faccbac55f7fc2b90f69a958
|
|
| MD5 |
676cc8574f3f5e9a6b983e941032902b
|
|
| BLAKE2b-256 |
ea48d4524980db6b0502599fbf7c1fa8df8d8a93a1d428ba82ed18eaead5f6e9
|
Provenance
The following attestation bundles were made for open_octopus-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on abracadabra50/open-octopus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_octopus-0.3.0-py3-none-any.whl -
Subject digest:
2f17dc9b05bbb46e15eee34746d97e3a7c9bbee7faccbac55f7fc2b90f69a958 - Sigstore transparency entry: 781160195
- Sigstore integration time:
-
Permalink:
abracadabra50/open-octopus@e811e7bae561a48de7f6c10fb6987a28d3468318 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/abracadabra50
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e811e7bae561a48de7f6c10fb6987a28d3468318 -
Trigger Event:
workflow_dispatch
-
Statement type: