Apologies for the dumb request, but I really cannot figure out how to install the CDS API key.
If I just copy the 2-line code on on how to ‘Install the CDS API key’ from the page 'How to use the CDS API | Copernicus Climate Data Store ’ on my terminal, I get the error ‘url: command not found’. If I use ’ curl ’ with the api key specified, I constantly get the error ‘401: Authorization Required’ . I am logged in and my API key and UID appear correctly.
Any help is appreciated!
Hi Nikita…
I’m also pretty new to CDS API, and found this post with some more details about how it works. Still figuring out how to access and handle the migration to the new services as the page seems to not work properly on my firfox browser.
If I manage to progress I’ll share details with you here.
Regards!
So it seems I’ve managed to request and download a subset of the climate data sheets by proceeding as follows:
-
ensured I have python3 installed
-
created a .cdsapi file on the user root folder (~/.cdsapirc)
-
filled the file with the API login details provided in the API -HOW-TO page. This has a shape similar to this:
url: https://cds.climate.copernicus.eu/api/v2
key: <UID>:<API key>
- Created a dedicated python environment for the CDS:
python3 -m venv ./
-
On the browser, I surfed to the Copernicus CDS and made a search, for instance, something like this.
-
on the selected data terms, I “defined” the desired parameters from the available variables of the search.
-
Submitted the request form, you can track its progress here.
-
After some “processing time”, the request is processed and, on the result, you can manually download or return to the dataset page and retrieve the API details.
-
When returning to the dataset page, you can (have to) accept the download terms, and a Show API button will be enabled, allowing you to copy the API Request text.
-
You can copy the python code and, in the path where you created your python environment, just execute python and paste the code directly on the prompt.
-
This will show you the progress of your request and, at finishing, provide you with an http url to download the data:
Hope this helps you moving onwards.
Kind regards!
P.S.- I cannot paste more than 1 image per post (barely new to this forum, moderation rules apply. ) I’ll post a pic of the python execution right now.
As commented, the python execution code would appeal something like this:
Also, despite this would be clear to you (I am pretty new to python too), it’s advisable to generate the python environment in an “ad-hoc” path to avoid mixing components, for instance I created a specific folder for copernicus (i.e., ~/copernicus/datasets), navigated to that folder, and executed the python environment creation in that subfolder:
cd ~/copernicus/datasets/
python3 -m venv ./
./bin/python
Python 3.11.2 (main, May 2 2024, 11:59:08) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Hope this is of help!
Regards.