We have updated some of the gridded products from the UKCP Regional (12km) data. Please read the news article for more details
The UKCP Application Programming Interface (API)

Going beyond the GUI: the web API

One way of making web-functionality available is to create a graphical user interface (GUI). This allows a user with a web browser to click through pages and forms in order to make requests to a service. For a tool such as UKCP, with potentially millions of outputs, the GUI approach becomes limiting when the user wants to request a large number of outputs. Equally, if the user might wish to automate requests to the service - which is very hard to achieve through a web browser.

Introduction the web API approach

An alternative interface to the web GUI is the Application Programming Interface (API). This provides a "programmatic" interface rather than a visual interface. An API can be called by a remote computer, opening up the possibility of applications, models and programmes talking to it directly.

You might consider using the web API if:
  • you need to make a large number of requests (such as requesting and output for every location and every variable)
  • you are running a computer model that requires UKCP data as an input
  • you are building an application that needs dynamic access to UKCP data/plots

Ready to get started

For more information see our API Getting Started page.

Your API key

Your home page shows the API key attached to your account. You will need to add it to each URL when you make requests directly to the WPS API.

What does the API look like?

The easiest way to demonstrate the API is to give an example. All you need to do is build a URL with the appropriate components to define your request. Note that every time you complete a WPS request through the web GUI you are shown the URL that can be used to regenerate that request. In fact, you can even select that request and paste it into your browser in order to re-run it (provided you are logged in).

Here is an example request URL, some white space has been added to make it more legible:

							https://ukclimateprojections-ui.metoffice.gov.uk/wps/Execute?
    Request=Execute&
    Identifier=LS1_CDF_PDF_01&
    Format=text/xml&
    Inform=true&
    Store=false&
    Status=false&
    DataInputs=
        Area=point|245333.38|778933.24;
        Baseline=b8100;
        Collection=land-prob;
        ColourMode=c;
        DataFormat=csv;
        FontSize=m;
        ImageFormat=png;
        ImageSize=1200;
        LegendPosition=7;
        PlotType=PDF_PLOT;
        Scenario=sres-a1b;
        TemporalAverage=jul;
        TimeSlice=2050-2069;
        TimeSliceDuration=20y;
        Variable=tasAnom;&
    ApiKey=<YOUR_API_KEY>
						

Key parameters:
  • Inform This flag can be set to 'true' or 'false'. If true, an email notification will be sent when the product is ready.
  • DataInputs These are the values used as inputs to the job to generate the product.
  • ApiKey This is required when you are using the API to authorise you to use the service.

Interpreting the API response

The WPS will quickly return a response from the API is a WPS in the form of an "Execute Response" XML document. The XML document will include a "statusLocation" URL in the second line (the "ExecuteResponse" XML element). Another important component of the XML document is the "Status" element - this will indicate whether the request has been accepted, has started running or has failed.

If the status shows as "ProcessFailed" then there has been an error in interpreting your request. The "Status" element should include an error message providing some information about the issue that caused the job to fail.

Assuming the request was accepted, it will be queued or running on the UKCP WPS servers. You can copy the "statusLocation" URL and poll it in order to get an updated version of the "Execute Response" document. Again, view the "Status" element to find out the current status.

Downloading the outputs - append the API Key

Once the "Status" shows as "ProcessSucceeded" then you can proceed to download your outputs. Search the XML document for the "FileURL" elements which contain URLs that you can download the outputs from. The ".zip" outputs should be downloaded as they contain all other files listed.

Please note that you must append the following to the download URL in order to be able to download the file via the web API: ?ApiKey=<YOUR_API_KEY>