wiki:DownscalingPortal/RESTfulAPI/Climate4Impact

Version 6 (modified by vegasm, 5 years ago) (diff)

DP REST ENDPOINTS

Climate4Impact

The Downscaling Portal RESTful API is token based authentication. That means, the user has to include a token in every request.

Access the API

Climate4Impact has an existing account into the Downscaling Portal. With the credentials provided is very simple to authenticate and get the token.

curl -i -X POST -d username=your_username -d password=your_password http://meteo.unican.es/dp/rest/authenticate

Success

HTTP/1.1 201 Created
Date: Mon, 24 Mar 2014 08:59:04 GMT
token: your_token
Content-Length: 0
Content-Type: text/plain

User Administration

The API allows the manager to create users who have the same experiments as him and this users will be attached to the manager. Thus, users can be added, listed and removed from the DPRA Climate4Impact service.

In order to clarify how to use the API quickly, we are going to follow an example step by step.

1. Create a new user

curl -i -H "Accept: application/json" -H "Content-type: application/json" -H "token: your_token" -X POST -d "{\"username\": \"pcmdi9.llnl.gov.openid.vegasm\", \"email\": \"vegasm@unican.es\", \"openID\": \"https://pcmdi9.llnl.gov/openid/vegasm\"}" http://meteo.unican.es/dp/rest/users

Response

HTTP/1.1 201 Created
Date: Mon, 24 Mar 2014 09:08:17 GMT
Content-Length: 0
Content-Type: text/plain

If the request generates an exception or something is missing, an error will be shown. Note: In some cases, it is possible that the character " has not to be escaped.

2. List users

curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/users

Success

HTTP/1.1 200 OK
Date: Mon, 24 Mar 2014 08:59:48 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

{"responseCode":"success","message":"List of users retrieved","values":[{"username":"pcmdi9.llnl.gov.openid.vegasm","password":null,"email":"vegasm@unican.es","openID":"pcmdi9.llnl.gov.openid.vegasm"}]}

3.Remove user

curl -i -H "Accept: application/json" -H "Content-type: application/json" -H "token: your_token" -X DELETE http://meteo.unican.es/dp/rest/users/pcmdi9.llnl.gov.openid.vegasm

Success

HTTP/1.1 200 OK
Date: Mon, 24 Mar 2014 09:00:59 GMT
Content-Length: 0
Content-Type: text/plain

Variables

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/variables

Variables by VariableType?

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/variables?variableType=TEMPERATURE

Zones

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/zones

Zone

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/zones/{zoneId}

Example: ZONE_ID=2637

Predictor

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/zones/{zoneId}/predictor

User Predictands

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/predictands

Zone Predictands

https://meteo.unican.es/dp/rest/zones/{ZONE_ID}/predictands

Filtered predictands

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/predictands?dataset={DATASET_NAME}&variable={VARIABLE_NAME}&domain={DOMAIN_NAME}

Optional parameter for clients: username. (Get predictands from the given user)

VARIABLE_NAME examples: TN TX, RR...

Domains

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/domains

Datasets

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/datasets

Stations

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/zones/{ZONE_ID}/predictands/{PREDICTAND_NAME}/stations

Models

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/models?zone={ZONE_ID}

Models filtering

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/models?zone={ZONE_ID}&project={PROJECT_NAME}&experiment={EXPERIMENT_NAME}&ensemble={ENSEMBLE_NAME}
Example: https://meteo.unican.es/dp/rest/models?zone=2637&project=CMIP5&experiment=historical&ensemble=r1i1p1

Model scenarios

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/models/{MODEL_NAME}/scenarios
Example: https://meteo.unican.es/dp/rest/models/CANESM2/scenarios

Jobs

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/jobs

Downscalings

curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/downscalings?zone={ZONE_ID}&predictand={PREDICTAND_NAME}x&downscalingMethod=Analogues%20(default)&downscalingType={DOWNSCALING_TYPE_NAME}&model={MODEL_NAME}&project={PROJECT_NAME}&experiment={EXPERIMENT_NAME}&ensemble={ENSEMBLE_NAME}
Example: http://meteo.unican.es/dp/rest/downscalings?zone=2637&predictand=VALUE_Iberia_ECA_Tmax&downscalingMethod=Analogues%20(default)&downscalingType=CLIMATE_CHANGE&model=GFDL-ESM2M&project=CMIP5&experiment=historical&ensemble=r1i1p1

Downscaling methods

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/zones/{ZONE_ID}/predictands/{PREDICTAND_NAME}/downscalingMethods

Delete job

curl -X DELETE-i -H "token: your_token" localhost:8080/dp/rest/jobs/{JOB_ID}

WARNING: you can only delete non owner jobs if you are the client. For this purpose use "username" parameter.

Downscaling download CSV

curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/downscalings/download4?jobId=33221&zone=2637&predictand=VALUE_Iberia_ECA_Tmax&downscalingMethod=Analogues%20(default)&model=GFDL-ESM2M&experiment=historical_r1i1p1&sYear=1951&eYear=1961&username=ceda.ac.uk.openid.Vega.Manuel&type=CLIMATE_CHANGE
Example: http://meteo.unican.es/dp/rest/downscalings/download4?jobId=33221&zone=2637&predictand=VALUE_Iberia_ECA_Tmax&downscalingMethod=Analogues%20(default)&model=GFDL-ESM2M&experiment=historical_r1i1p1&sYear=1951&eYear=1961&username=ceda.ac.uk.openid.Vega.Manuel&type=CLIMATE_CHANGE

Downscaling download NetCDF4

curl -i -H "token: your_token" http://meteo.unican.es/dp/rest/downscalings/download4?jobId={JOB_ID}&zone={ZONE_ID}&predictand={PREDICTAND_NAME}&downscalingMethod={DOWNSCALING_METHOD_NAME}&model={MODEL_NAME}&experiment={EXPERIMENT_NAME}&sYear={START_YEAR}&eYear={END_YEAR}&type={TYPE_name}

Optional: "username" parameter for clients.

Example: http://meteo.unican.es/dp/rest/downscalings/download4?jobId=33221&zone=2637&predictand=VALUE_Iberia_ECA_Tmax&downscalingMethod=Analogues%20(default)&model=GFDL-ESM2M&experiment=historical_r1i1p1&sYear=1951&eYear=1961&username=ceda.ac.uk.openid.Vega.Manuel&type=CLIMATE_CHANGE

JOB LOG

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/jobs/{JOB_ID}/log

WARNING: only for downscaling jobs from DP 2.1 update. "username" parameter available for clients.

DP ESGF-Search experimental end-point

curl -i -H "token: your_token" https://meteo.unican.es/dp/rest/ESGF/gcm

Launch downscaling

curl -i -H "token: your_token" --data="zone={ZONE_ID}&predictand={PREDICTAND_NAME}&downscalingMethod={DOWNSCALING_METHOD}&model={MODEL_NAME}&experiment={EXPERIMENT_NAME}&sYear={START_YEAR}&eYear={END_YEAR}" https://meteo.unican.es/dp/rest/downscale

WARNING: "username" parameter available for clients.