Problems to execute the simple CDS API client for data access (Python)

Hi,

I’m trying to execute the Python code example provided at
https://cds.climate.copernicus.eu/how-to-api

import cdsapi

client = cdsapi.Client()

dataset = 'reanalysis-era5-pressure-levels'
request = {
  'product_type': ['reanalysis'],
  'variable': ['geopotential'],
  'year': ['2024'],
  'month': ['03'],
  'day': ['01'],
  'time': ['13:00'],
  'pressure_level': ['1000'],
  'data_format': 'grib',
}
target = 'download.grib'

client.retrieve(dataset, request, target)

Previously, I created the ‘%USERPROFILE%.cdsapirc’ file with the contents of the blackbox. If I use the exact content of the blackbox, I get the following error message:

The cdsapi key provided is not the correct format, please ensure it conforms to:
<UID>:<APIKEY>

If I change the second line with:
<MY_EMAIL_ADDRESS>:

I get the following error message
HTTPError: 404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-pressure-levels

Any help is appreciated

Hi Manuel!

I think I could help. I had the same isue hour ago.
How ECMWF has new system and API you have to update your credentials file and update cdsapi library with pip to use the newer version.

In .cdsapirc file, the format for your credentials would be like:

url: https://cds.climate.copernicus.eu/api
key: your-number-key

And if you want to update cdsapi library yo can use:

pip install cdsapi --upgrade

I hope this help you.

  • Eduardo Loza

Hey, I have this same issue and updating cdsapi did not work, is there any other tips to overcome this issue?
Thanks,
-Anni

Hey again, my issue was fixed with changing the url in the cdsapirc file to url: https://ewds.climate.copernicus.eu/api as the data I needed is from CEMS early warning data store, and not anymore from CDS. But cdsapi needed to be updated too.
-Anni

1 Like