Octopus give an example of the command needed to access their API:

curl -u "sk_live_************************:" "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-M/standard-unit-rates/"

The ************************ represents what will be my password or unique key

My code is:

import urllib.request

curlplusurl = 'curl -u "sk_live_************************:" "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-M/standard-unit-rates/"'

with urllib.request.urlopen(curlplusurl) as response 
    answer = response.read()

I get the following error:

raise URLError('unknown url type: %s' % type)

urllib.error.URLError: urlopen error unknown url type: curl -u "sk_live_************************

the bit with the password/unique key is vital - so how do I give it if I can't do it the way Octopus describe?

  • Could you please edit the post using the code function - the important bit (where you build the URL) is split. I would do this for you but its better if you do so the code can be checked by the author :-). Also - do you have a link to the API documentation from Octopus that you could include?
    – user115418
    Apr 13, 2020 at 23:23

1 Answer 1


To solve this you can use the download manager in the octopy-energy library (disclosure: which I've written) - https://ayrtonb.github.io/Octopy-Energy/

from octopyenergy.api import DownloadManager

octopus_api_key = 'your_octopus_api_key'
meter_mpan = 'your_meter_mpan'
meter_serial = 'your_meter_serial'

download_manager = DownloadManager(meter_mpan=meter_mpan, 

s_elec_consumption = download_manager.create_elec_consumption_s()


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.