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

Using the URL obtained in the example above it is possible to construct a script to call the api. For example:

							import urllib2

api_key = "<YOUR_API_KEY>"

months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
          "nov", "dec"]

url_template = (""

for month in months:
    url = url_template.format(month=month,api_key=api_key)
    response = urllib2.urlopen(url)
    xml_doc =