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? – Andyroo Apr 13 at 23:23

Your Answer

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

Browse other questions tagged or ask your own question.