Wrapper for communicating with the Octopus Energy API
Project description
GitHub: github.com/euanacampbell/octopus_energy_api
PyPi: pypi.org/project/octopus-energy-api
Installation
pip install octopus-energy-api
Import
from octopus_energy_api import oe_api
Usage
Two ways of creating an API instance.
Load access details in manually - Can be found using this fantastic tutorial by Guy Lipman guylipman.medium.com.
from octopus_energy_api import oe_api
api_key = ""
mpan = ""
serial_number = ""
account_number = ""
energy_api = oe_api(api_key=api_key, mpan=mpan, serial_number=serial_number, account_number=account_number)
Get mpan and serial numbers from account number + api key. (currently only works for single property accounts)
from octopus_energy_api import oe_api
api_key = "value here"
account_number = "value here"
account_details = oe_api.get_mpan_serial(account_number, api_key)
mpan = account_details['mpan']
serial_number = account_details['serial_numbers'][1] # may have multiple
energy_api = oe_api(api_key=api_key, mpan=mpan, serial_number=serial_number, account_number=account_number)
To confirm this worked, the below can be used. A valid response should be returned.
energy_api.account_details()
Getting Consumption Data
from octopus_energy_api import oe_api
import datetime
energy_api = oe_api(api_key, mpan, serial_number, account_number)
today = datetime.date.today() # setting end date to today
start = today.replace(day=1) # setting start date to the beginning of the month
energy_api.get_consumption(start, today)
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
octopus_energy_api-0.5.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for octopus_energy_api-0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44d1ad9cece00423d9c0befba4bd32cf4c0da84cccdb345231c42d13d61b9a4b |
|
MD5 | f33932ca891a5d8ade70fb8cec1d8d82 |
|
BLAKE2b-256 | c3734be605b0c62e47f91583eb46f1dbc62cc4a794eccd17869fdba6a159b6a0 |