The CDS API is a service providing programmatic access to ADS data. In this page you will find explanations and examples showing how to use the CDS API
For Windows users, please read How to install and use CDS API on Windows
For macOS users, please read How to install and use CDS API on macOS
For linux users, please proceed as follows:
If, after installing the API, you encounter errors in your requests please consult this page on common error messages for CDS requests.
- If you don't have an account, please self register at the ADS registration page and go to the steps below.
-
If you are not logged, please login and go to the step below.
-
Copy the code displayed beside, in the file $HOME/.cdsapirc (in your Unix/Linux environment).
(Note that the separate Copernicus Climate Change Service uses the same CDS API software while providing access to different datasets. If you are using this service and so already have a key stored in ~/.cdsapirc then you will have to store your ADS key elsewhere and pass the key information to the client library explicitly. See below for more details).
The CDS API client is a python based library. It provides support for both Python 2.7.x and Python 3.
You can Install the CDS API client via the package management system pip
, by running on Unix/Linux the command shown in the box beside.
Once the CDS API client is installed, it can be used to request data from the datasets listed in the CDS catalogue. It is necessary to agree to the Terms of Use of every datasets that you intend to download.
Attached to each dataset download form, the following button displays the python code to be used. The request can be formatted using the interactive form. The api call must follow the syntax:
import cdsapi c = cdsapi.Client() c.retrieve("dataset-short-name", {... sub-selection request ...}, "target-file")
If you have more than one CDS API key and therefore have to pass credentials in explicitly (see above) you can use the following method:
import cdsapi import yaml with open('/path/to/ads/cdsapirc', 'r') as f: credentials = yaml.safe_load(f) c = cdsapi.Client(url=credentials['url'], key=credentials['key']) c.retrieve("dataset-short-name", {... sub-selection request ...}, "target-file")