The UKCP Application Programming Interface (API) - Getting Started

A walk-through of how to use the API key

The following steps will help get you started:
  1. Log in to the web site and run a process
  2. On the job viewer page copy the URL
    • When the process has finished go to the Job Details tab
    • Use the embedded copy button to copy the Job Request URL
  3. Modify the inputs as required
    • Initially just keep them the same
    • Later you could try changing the TimeSlice to 2000|2030 or the TimePeriod to jun
  4. Test in the browser
    • Paste the URL into a browser
    • You should get an XML response telling you the job has run
    • The XML includes details of the job as well as links to the outputs generated

Using the API directly from code

You can directly interact with the API via your own code. However, due to the complex interactions between the client and server (see diagram here) we strongly recommend that you use the freely available UKCP API Python Client library. The example code shown below makes use of this client library:

							from ukcp_api_client.client import UKCPApiClient
api_key = "<YOUR_API_KEY>"

cli = UKCPApiClient(outputs_dir="my-outputs", api_key=api_key)

request_url = ";Area=bbox|474459.24|241777.72|486311.19|246518.35;Collection=land-rcm;ClimateChangeType=absolute;EnsembleMemberSet=land-rcm;DataFormat=csv;TimeSlice=2075|2076;Variable=psl"

file_urls = cli.submit(request_url)