octo_api.products

Classes to model products and tariffs.

Classes:

BaseProduct(available_from, available_to, …)

Represents an Octopus Energy product.

Product(available_from, available_to, brand, …)

Represents an Octopus Energy product.

DetailedProduct(available_from, …)

Represents an Octopus Energy product, with detailed tariff information.

Tariff(code, standing_charge_exc_vat, …[, …])

Represents a tariff for a product.

RateInfo(value_exc_vat, value_inc_vat, …)

Represents the unit rate of a tariff at a particular period in time.

RegionalTariffs

Mapping of GSP regions to a mapping of payment methods to Tariffs.

RegionalQuotes

Mapping of GSP regions to a mapping of payment methods to a mapping of fuel types to Quotes.

class BaseProduct(available_from, available_to, brand, code, description, display_name, full_name, is_business, is_green, is_prepay, is_restricted, is_tracker, is_variable, links, term)[source]

Bases: object

Represents an Octopus Energy product.

Parameters
  • available_from (Union[str, datetime, None]) – The date from which the product is available.

  • available_to (Union[str, datetime, None]) – The date until which the product is available.

  • brand (str) – The brand under which the product is sold.

  • code (str) – The tariff code.

  • description (str) – A description of the product.

  • display_name (str) – The display name of the product.

  • full_name (str) – The name of the product.

  • is_business (bool) – Whether the product is for businesses.

  • is_green (bool) – Whether the product is green.

  • is_prepay (bool) – Whether the product is prepay.

  • is_restricted (bool) – Whether the product is restricted.

  • is_tracker (bool) – Whether the product tracks the wholesale electricity rate.

  • is_variable (bool) – Whether the product has a variable tariff.

  • links (Iterable[MutableMapping[str, Any]]) – Links associated with this product.

  • term (Optional[int]) – The number of months that a product lasts for if it is fixed length.

Attributes:

available_from

The date from which the product is available.

available_to

The date until which the product is available.

brand

The brand under which the product is sold.

code

The code of the product.

description

A description of the product.

display_name

The display name of the product.

full_name

The name of the product.

is_business

Whether the product is for businesses.

is_green

Whether the product is green.

is_prepay

Whether the product is prepay.

is_restricted

Whether the product is restricted.

is_tracker

Whether the product tracks the wholesale electricity rate.

is_variable

Whether the product has a variable tariff.

links

Links associated with this product.

term

The number of months that a product lasts for if it is fixed length.

Methods:

from_dict(d)

Construct an instance of BaseProduct from a dictionary.

to_dict([convert_values])

Returns a dictionary containing the contents of the BaseProduct object.

available_from

Type:    Optional[datetime]

The date from which the product is available.

available_to

Type:    Optional[datetime]

The date until which the product is available.

brand

Type:    str

The brand under which the product is sold.

code

Type:    str

The code of the product.

description

Type:    str

A description of the product.

display_name

Type:    str

The display name of the product.

classmethod from_dict(d)

Construct an instance of BaseProduct from a dictionary.

Parameters

d (Mapping[str, Any]) – The dictionary.

full_name

Type:    str

The name of the product.

is_business

Type:    bool

Whether the product is for businesses.

is_green

Type:    bool

Whether the product is green.

is_prepay

Type:    bool

Whether the product is prepay.

is_restricted

Type:    bool

Whether the product is restricted.

is_tracker

Type:    bool

Whether the product tracks the wholesale electricity rate.

is_variable

Type:    bool

Whether the product has a variable tariff.

Type:    List[MutableMapping[str, Any]]

Links associated with this product.

term

Type:    Optional[int]

The number of months that a product lasts for if it is fixed length.

to_dict(convert_values=False)

Returns a dictionary containing the contents of the BaseProduct object.

Parameters

convert_values (bool) – Recursively convert values into dictionaries, lists etc. as appropriate. Default False.

Return type

MutableMapping[str, Any]

class Product(available_from, available_to, brand, code, description, display_name, full_name, is_business, is_green, is_prepay, is_restricted, is_tracker, is_variable, links, term, direction)[source]

Bases: octo_api.products.BaseProduct

Represents an Octopus Energy product.

Parameters
  • available_from (Union[str, datetime, None]) – The date from which the product is available.

  • available_to (Union[str, datetime, None]) – The date until which the product is available.

  • brand (str) – The brand under which the product is sold.

  • code (str) – The tariff code.

  • description (str) – A description of the product.

  • display_name (str) – The display name of the product.

  • full_name (str) – The name of the product.

  • is_business (bool) – Whether the product is for businesses.

  • is_green (bool) – Whether the product is green.

  • is_prepay (bool) – Whether the product is prepay.

  • is_restricted (bool) – Whether the product is restricted.

  • is_tracker (bool) – Whether the product tracks the wholesale electricity rate.

  • is_variable (bool) – Whether the product has a variable tariff.

  • links (Iterable[MutableMapping[str, Any]]) – Links associated with this product.

  • term (Optional[int]) – The number of months that a product lasts for if it is fixed length.

  • direction (str) – The direction of the product (supply to the customer or supply to the grid).

Attributes:

direction

The direction of the product (supply to the customer or supply to the grid).

direction

Type:    str

The direction of the product (supply to the customer or supply to the grid).

class DetailedProduct(available_from, available_to, brand, code, description, display_name, full_name, is_business, is_green, is_prepay, is_restricted, is_tracker, is_variable, links, term, tariffs_active_at, single_register_electricity_tariffs, dual_register_electricity_tariffs, single_register_gas_tariffs, sample_quotes, sample_consumption)[source]

Bases: octo_api.products.BaseProduct

Represents an Octopus Energy product, with detailed tariff information.

Each *_tariffs object will have up to 14 keys; one for each GSP. For each GSP the applicable tariffs are listed under their associated payment method, e.g. direct_debit_monthly.

  • The standard_unit_rate_* values are listed in p/kWh (pence per kilowatt hour).

  • The standing_charge_* values are listed in p/day (pence per day).

  • The annual_cost_* values are listed in p (pence).

Parameters
  • available_from (Union[str, datetime, None]) – The date from which the product is available.

  • available_to (Union[str, datetime, None]) – The date until which the product is available.

  • brand (str) – The brand under which the product is sold.

  • code (str) – The tariff code.

  • description (str) – A description of the product.

  • display_name (str) – The display name of the product.

  • full_name (str) – The name of the product.

  • is_business (bool) – Whether the product is for businesses.

  • is_green (bool) – Whether the product is green.

  • is_prepay (bool) – Whether the product is prepay.

  • is_restricted (bool) – Whether the product is restricted.

  • is_tracker (bool) – Whether the product tracks the wholesale electricity rate.

  • is_variable (bool) – Whether the product has a variable tariff.

  • links (Iterable[MutableMapping[str, Any]]) – Links associated with this product.

  • term (Optional[int]) – The number of months that a product lasts for if it is fixed length.

  • tariffs_active_at (Union[str, datetime, None])

  • single_register_electricity_tariffs (Dict[str, Dict[str, Dict[str, Any]]]) – Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

  • dual_register_electricity_tariffs (Dict[str, Dict[str, Dict[str, Any]]]) – Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

  • single_register_gas_tariffs (Dict[str, Dict[str, Dict[str, Any]]]) – Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

  • sample_quotes (Dict[str, Dict[str, Dict[str, Any]]])

  • sample_consumption (Dict)

Attributes:

dual_register_electricity_tariffs

Mapping of GSPs to applicable tariffs for each payment method, e.g.

sample_consumption

sample_quotes

single_register_electricity_tariffs

Mapping of GSPs to applicable tariffs for each payment method, e.g.

single_register_gas_tariffs

Mapping of GSPs to applicable tariffs for each payment method, e.g.

tariffs_active_at

Methods:

from_dict(d)

Construct an instance of DetailedProduct from a dictionary.

to_dict([convert_values])

Returns a dictionary containing the contents of the DetailedProduct object.

dual_register_electricity_tariffs

Type:    Dict

Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

classmethod from_dict(d)

Construct an instance of DetailedProduct from a dictionary.

Parameters

d (Mapping[str, Any]) – The dictionary.

sample_consumption

Type:    Dict

sample_quotes

Type:    Dict

single_register_electricity_tariffs

Type:    Dict

Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

single_register_gas_tariffs

Type:    Dict

Mapping of GSPs to applicable tariffs for each payment method, e.g. direct_debit_monthly.

tariffs_active_at

Type:    Optional[datetime]

to_dict(convert_values=False)

Returns a dictionary containing the contents of the DetailedProduct object.

Parameters

convert_values (bool) – Recursively convert values into dictionaries, lists etc. as appropriate. Default False.

Return type

MutableMapping[str, Any]

class RateInfo(value_exc_vat, value_inc_vat, valid_from, valid_to)[source]

Bases: object

Represents the unit rate of a tariff at a particular period in time.

Parameters
  • value_exc_vat (float) – In p/kWh (pence per kilowatt hour).

  • value_inc_vat (float) – In p/kWh (pence per kilowatt hour).

  • valid_from (Union[str, datetime, None]) – The date and time from which this rate is in effect.

  • valid_to (Union[str, datetime, None]) – The date and time until which this rate is in effect, or None if this rate continues in perpetuity.

Methods:

from_dict(d)

Construct an instance of RateInfo from a dictionary.

to_dict([convert_values])

Returns a dictionary containing the contents of the RateInfo object.

Attributes:

valid_from

The date and time from which this rate is in effect.

valid_to

The date and time until which this rate is in effect, or None if this rate continues in perpetuity.

value_exc_vat

In p/kWh (pence per kilowatt hour).

value_inc_vat

In p/kWh (pence per kilowatt hour).

classmethod from_dict(d)

Construct an instance of RateInfo from a dictionary.

Parameters

d (Mapping[str, Any]) – The dictionary.

to_dict(convert_values=False)

Returns a dictionary containing the contents of the RateInfo object.

Parameters

convert_values (bool) – Recursively convert values into dictionaries, lists etc. as appropriate. Default False.

Return type

MutableMapping[str, Any]

valid_from

Type:    datetime

The date and time from which this rate is in effect.

valid_to

Type:    Optional[datetime]

The date and time until which this rate is in effect, or None if this rate continues in perpetuity.

value_exc_vat

Type:    float

In p/kWh (pence per kilowatt hour).

value_inc_vat

Type:    float

In p/kWh (pence per kilowatt hour).

class Tariff(code, standing_charge_exc_vat, standing_charge_inc_vat, online_discount_exc_vat, online_discount_inc_vat, dual_fuel_discount_exc_vat, dual_fuel_discount_inc_vat, exit_fees_exc_vat, exit_fees_inc_vat, links, standard_unit_rate_exc_vat=None, standard_unit_rate_inc_vat=None, day_unit_rate_exc_vat=None, day_unit_rate_inc_vat=None, night_unit_rate_exc_vat=None, night_unit_rate_inc_vat=None)[source]

Bases: object

Represents a tariff for a product.

Parameters
  • code (str) – The tariff code.

  • standing_charge_exc_vat (float) – In p/day (pence per day).

  • standing_charge_inc_vat (float) – In p/day (pence per day).

  • online_discount_exc_vat (int)

  • online_discount_inc_vat (int)

  • dual_fuel_discount_exc_vat (int)

  • dual_fuel_discount_inc_vat (int)

  • exit_fees_exc_vat (int)

  • exit_fees_inc_vat (int)

  • links (List[Dict[str, Any]]) – Links associated with this product.

  • standard_unit_rate_exc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

  • standard_unit_rate_inc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

  • day_unit_rate_exc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

  • day_unit_rate_inc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

  • night_unit_rate_exc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

  • night_unit_rate_inc_vat (Optional[float]) – In p/kWh (pence per kilowatt hour). Default None.

Methods:

from_dict(d)

Construct an instance of Tariff from a dictionary.

to_dict([convert_values])

Returns a dictionary containing the contents of the Tariff object.

classmethod from_dict(d)

Construct an instance of Tariff from a dictionary.

Parameters

d (Mapping[str, Any]) – The dictionary.

to_dict(convert_values=False)

Returns a dictionary containing the contents of the Tariff object.

Parameters

convert_values (bool) – Recursively convert values into dictionaries, lists etc. as appropriate. Default False.

Return type

MutableMapping[str, Any]

class RegionalTariffs[source]

Bases: Dict[str, Dict[str, Tariff]]

Mapping of GSP regions to a mapping of payment methods to Tariffs.

Methods:

__str__()

Return str(self).

__str__()[source]

Return str(self).

Return type

str