I’m trying to update my scripts (running on a linux jupyterhub server) to the new API, and I’m running into some issues.
Firstly, when I follow the instructions to set the contents of my .cdsapirc file (Climate Data Store) I get:
AssertionError: The cdsapi key provided is not the correct format, please ensure it conforms to:
<UID>:<APIKEY>
If I change my .cdsapirc file to include my user ID as instructed, then the error disappears. However, I’m unable to download anything, and always get a 404 client error. I’ve attached an example below. Any thoughts as to what is going wrong?
dataset = "reanalysis-era5-pressure-levels"
request = {
"product_type": ["reanalysis"],
"variable": ["temperature"],
"year": ["2018"],
"month": ["10"],
"day": ["11"],
"time": [
"08:00"
],
"pressure_level": ["1000"],
"data_format": "grib",
"download_format": "unarchived"
}
client = cdsapi.Client()
client.retrieve(dataset, request).download()
2025-01-20 16:35:22,779 INFO Sending request to https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-pressure-levels
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~/.local/lib/python3.9/site-packages/cdsapi/api.py in _api(self, url, request, method)
441 try:
--> 442 result.raise_for_status()
443 reply = result.json()
/opt/anaconda3/envs/qgis/lib/python3.9/site-packages/requests/models.py in raise_for_status(self)
942 if http_error_msg:
--> 943 raise HTTPError(http_error_msg, response=self)
944
HTTPError: 404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-pressure-levels
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
<ipython-input-3-1292a4c640e9> in <module>
15
16 client = cdsapi.Client()
---> 17 client.retrieve(dataset, request).download()
~/.local/lib/python3.9/site-packages/cdsapi/api.py in retrieve(self, name, request, target)
362
363 def retrieve(self, name, request, target=None):
--> 364 result = self._api("%s/resources/%s" % (self.url, name), request, "POST")
365 if target is not None:
366 result.download(target)
~/.local/lib/python3.9/site-packages/cdsapi/api.py in _api(self, url, request, method)
462 )
463 error = ". ".join(e)
--> 464 raise Exception(error)
465 else:
466 raise
Exception: Not Found