PV_Live Public API User Guide

PV_Live

Contents

Contents

Introduction

Using the API

Response format

Web browser

Command line

Python

pvlive.py

Introduction

The PV-Live web API (Application Programming Interface) provides access to the LIVE estimate of PV generation in the UK. It returns a computer friendly (JSON) response for use in software, websites, apps etc.

Using the API

Warning: The PV-Live API is under active development.We may change: base-url, end-points, authentication, response format etc.

Response format

The following examples all return a JSON response like this:

{

"Substation_id":"0",

"timestamp_GMT":"2016-05-17 13:15:10",

"datetime_GMT":"2016-05-17 13:00:00",

"generation_MW":"4410",

"uncertainty_MW":null,

"Stats_error":"44",

"Bias_error":null,

"lcl_MW":"4230",

"ucl_MW":"4590",

"Version_id":"46",

"capacity_MWp":"10340",

"installedcapacity_MWp":"10500",

"Site_count":"311",

"Calculation_time_s":"8"

}

Where:

Web browser

Visit: https://www.solar.sheffield.ac.uk/ssfdb3/crud/nationalgrid/pvnowcast/0

username: pvlive

password: (None. So leave this empty)

Command line

$ curl --user pvlive: --url https://www.solar.sheffield.ac.uk/ssfdb3/crud/nationalgrid/pvnowcast/0

$ wget -qO- --password=  --user=pvlive https://www.solar.sheffield.ac.uk/ssfdb3/crud/nationalgrid/pvnowcast/0

(Note both of these provide a username and empty password.)

Python

The demo script below, pvlive.py, shows how the API can be queried in Python.

pvlive.py

#!/usr/bin/python3

import requests

class Querier(object):

    def __init__(self, url_base, username, password):

        self.url_base=url_base

        self.username=username

        self.password=password

    def query(self, substation_id):

        return requests.get(self.url_base + str(substation_id),

                            auth=requests.auth.HTTPBasicAuth(self.username,

                                                             self.password))

if __name__ == '__main__':

    url_base='https://www.solar.sheffield.ac.uk/ssfdb3/crud/' \

             'nationalgrid/pvnowcast/'

    username='pvlive'

    password=''     #2 single quotes i.e. empty string

    querier = Querier(url_base, username, password)

    substation_id=0

    response = querier.query(substation_id)

    print(response.text)


Updated: Fri Sep 01 2017 10:33:23 GMT+0100 (BST)