API reference
data: str
property
Return json formated calculations settings.
Example
account.data
set_energy(energy_type)
Set energy type for succeeding methods that rely on an optional energy_type parameter.
Example
account.set_energy('gas')
Parameters:
-
energy_type
(str
) –The energy type to set.
add_bill(self, energy_type=None)
Add the account bill to the calculation methods.
Examples:
>>> account.add_bill()
Parameters:
-
energy_type
–Set the energy type for which the bill should be calculated.
add_method(self, name, tariff_agreements, energy_type=None, replace=False)
Add a calculation method using a custom tariff list.
Examples:
>>> custom_list = [
{
"tariff_code": "E-1R-VAR-22-10-01-C",
"valid_from": "2023-03-17 00:00:00+00:00",
"valid_to": "2023-03-18 00:00:00+00:00"
},
{
"tariff_code": "E-1R-AGILE-FLEX-22-11-25-C",
"valid_from": "2023-03-18 00:00:00+00:00",
"valid_to": "2024-02-15 00:00:00+00:00"
},
{
"tariff_code": "E-1R-INTELLI-VAR-22-10-14-C",
"valid_from": "2024-02-15 00:00:00+00:00",
"valid_to": None
}
]
>>> account.add_method('Custom tariff', custom_list)
Parameters:
-
name
(str
) –The unique name for this calculation method.
-
tariff_agreements
(list
) –A custom list of tariff codes with valid from and valid to dates.
-
energy_type
(str | None
, default:None
) –The energy type for which to add this calculation method.
-
replace
(bool
, default:False
) –Whether to replace an existing calculation method with the same name.
add_method_by_product_code(self, product_code, energy_type=None)
Add a calculation method using an Octopus product code. e.g. "AGILE-23-12-06".
Examples:
>>> account.add_method_by_product_family('AGILE-23-12-06')
Parameters:
-
product_code
(str
) –The Octopus product code to add. e.g. "SILVER-23-12-06"
-
energy_type
(str | None
, default:None
) –Set the energy type for this particular method call.
add_method_by_product_family(self, family_name, energy_type=None)
Add a calculation method using an Octopus product family. e.g. "Agile Octopus". Only tariffs available in your local local Octopus products database will be added to the method.
Examples:
>>> account.add_method_by_product_family('Agile Octopus')
Parameters:
-
family_name
(str
) –The name of the Octopus product family to add. e.g. "Flexible Octopus"
-
energy_type
(str | None
, default:None
) –Set the energy type for this particular method call.
remove_method(self, name, energy_type=None)
Remove a calculation method.
Examples:
>>> account.remove_tariff('Bill')
Parameters:
-
name
(str
) –The name of the calculation method to remove.
-
energy_type
(str | None
, default:None
) –The energy type from which to remove the calculation method.
calculate(self, from_date=None, to_date=None, energy_type=None)
Calculate costs for the methods added.
Parameters:
-
from_date
(None | str | datetime
, default:None
) –A date from which to begin calculations.
-
to_date
(None | str | datetime
, default:None
) –A date to which calculate.
print_bill(self, from_date=None, to_date=None, energy_type=None)
Print the bill for the account.
Examples:
>>> account.print_bill()
>>> account.print_bill('2023-01-15', '2024-04-16')
Parameters:
-
from_date
(str | datetime
, default:None
) –The date from which to print the costs.
-
to_date
(str | datetime
, default:None
) –The date to which to print the costs.
-
energy_type
(str | None
, default:None
) –The energy type to use in the bill.
print_compare(self, from_date=None, to_date=None, energy_type=None)
Print a comparison table of all the calculation methods.
Examples:
>>> account.print_compare('Agile Octopus')
>>> account.print_compare('Flexible Octopus', '2023-01-15', '2024-04-16')
Parameters:
-
from_date
(str | datetime
, default:None
) –The date from which to print the comparion.
-
to_date
(str | datetime
, default:None
) –The date to which to print the comparion.
-
energy_type
(str | None
, default:None
) –The energy type to use in the comparion.
print_method(self, name, from_date=None, to_date=None, energy_type=None)
Print the bill for the specified calculation method.
Examples:
>>> account.print_method('Agile Octopus')
>>> account.print_method('Flexible Octopus', '2023-01-15', '2024-04-16')
Parameters:
-
from_date
(str | datetime
, default:None
) –The date from which to print the costs.
-
to_date
(str | datetime
, default:None
) –The date to which to print the costs.
-
energy_type
(str | None
, default:None
) –The energy type to use in the bill.
update(self, force_refresh=False)
Update/create consumption, account tariffs, Octopus products and existing tariff databases.
Examples:
>>> account.update()
Parameters:
-
force_refresh
(bool | None
, default:False
) –Whether to delete and recreate the databases.
update_by_product_code(self, product_codes, force_refresh=None, energy_type=None)
Update/create databases of supplied Octopus product codes.
Examples:
>>> product_codes = ['Agile Octopus', 'Flexible Octopus']
>>> account.update_by_product_code(product_codes)
OR
>>> account.update_by_product_code('Agile Octopus')
Parameters:
-
product_codes
(list | str
) –A list of Octopus product codes to update.
-
force_refresh
(bool | None
, default:None
) –Whether to delete and recreate the databases.
-
energy_type
(str | None
, default:None
) –Update for the specified energy type.
update_by_product_family(self, product_families, force_refresh=None, energy_type=None)
Update/create tariff databases of supplied Octopus product families. Only tariffs available in your local Octopus products database will be updated.
Examples:
>>> product_families = ['Agile Octopus', 'Flexible Octopus']
>>> account.update_by_product_family(product_families)
OR
>>> account.update_by_product_family('Flexible Octopus')
Parameters:
-
product_families
(list | str
) –A list of Octopus product families to update.
-
force_refresh
(bool | None
, default:None
) –Whether to delete and recreate the databases.
-
energy_type
(str | None
, default:None
) –Update for the specified energy type.
update_by_tariff_code(self, tariff_codes, force_refresh=None)
Update/create databases of supplied Octopus tariff codes.
Examples:
>>> tariff_codes = ['E-1R-AGILE-FLEX-22-11-25-C', 'E-1R-INTELLI-VAR-22-10-14-C']
>>> account.update_by_product_code(tariff_codes)
OR
>>> account.update_by_product_code('E-1R-AGILE-FLEX-22-11-25-C')
Parameters:
-
tariff_codes
(list
) –A list of Octopus tariff codes to update.
-
force_refresh
(bool | None
, default:None
) –Whether to delete and recreate the databases.
update_existing_products(self, force_refresh=None)
Update existing Octopus tariff databases.
Examples:
>>> account.update_existing_products()
Parameters:
-
force_refresh
(bool | None
, default:None
) –Whether to delete and recreate the databases.
update_products_database_by_product_code(self, product_codes)
Add product information to local Octopus products database.
Examples:
>>> product_codes = ['AGILE-FLEX-22-11-25', 'SILVER-FLEX-22-11-25']
>>> account.update_products_database_by_product_code(product_codes)
OR
>>> account.update_products_database_by_product_code('AGILE-FLEX-22-11-25')
Parameters:
-
product_codes
(list | str
) –A list of Octopus products to add to the products database.