cdsapi (Rust)
A Rust client for the Copernicus Climate Data Store (CDS) API, inspired by the Python cdsapi library.
This crate supports both CDS key formats currently seen in the wild:
- Legacy key:
<UID>:<APIKEY>→ uses the legacy/resources+/tasksworkflow. - Token-only key:
<PERSONAL_ACCESS_TOKEN>(no colon) → uses the modern Retrieve API (/api/retrieve/v1) withPRIVATE-TOKENauth.
Configuration
The client loads configuration from (highest precedence first):
- Environment variables:
CDSAPI_URLCDSAPI_KEYCDSAPI_RC(path to a config file)
- Config file in the current working directory:
./.cdsapirc - Config file in the home directory:
~/.cdsapirc
Example .cdsapirc:
url: https://cds.climate.copernicus.eu/api
key: <PERSONAL_ACCESS_TOKEN>
# or legacy:
# key: <UID>:<APIKEY>
Notes:
- The parser is lenient and also accepts
key:on one line and the value on the next line. - Set
verify: 0to disable TLS certificate validation (not recommended).
Usage
Library usage:
use Result;
use Client;
use json;
Example program:
Runtime output
The client prints request/job status transitions to stderr while polling (for example: Request state: running or Job status: accepted).
Troubleshooting
- 403 required licences not accepted:
- Sign in to the CDS web UI, open the dataset page, and accept the required licence(s) (often via “Manage licences”), then retry.
- 401/403 auth failures:
- Ensure your key is correct. Many token-only keys should NOT include the deprecated
<UID>:prefix.
- Ensure your key is correct. Many token-only keys should NOT include the deprecated
- 404 endpoint not found:
- Ensure
urlishttps://cds.climate.copernicus.eu/api(or your CDS deployment base URL).
- Ensure
License
Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.