Cannot download ERA5 data via CDS-API: "requests.exceptions.HTTPError: 404 Client Error" and "Exception: Not Found"

Hello, I am new to the CDS-API and I am struggling with using the CDS-API in downloading ERA5 reanalysis data through Windows OS. Here is my code:

import cdsapi

dataset = 'reanalysis-era5-pressure-levels'
request = {
    'product_type': ['reanalysis'],
    'variable': [
        'specific_humidity',
        'temperature',
        'u_component_of_wind',
        'v_component_of_wind',
        'vertical_velocity'
    ],
    'year': [
        '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993',
        '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002',
        '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011',
        '2012', '2013', '2014', '2015'
    ],
    'month': ['01', '12'],
    'day': [
        '01', '02', '03',
        '04', '05', '06',
        '07', '08', '09',
        '10', '11', '12',
        '13', '14', '15',
        '16', '17', '18',
        '19', '20', '21',
        '22', '23', '24',
        '25', '26', '27',
        '28', '29', '30',
        '31'
    ],
    'time': [
        '00:00', '03:00', '06:00',
        '09:00', '12:00', '15:00',
        '18:00', '21:00'
    ],
    'pressure_level': [
        '100', '125', '150',
        '175', '200', '225',
        '250', '300', '350',
        '400', '450', '500',
        '550', '600', '650',
        '700', '750', '775',
        '800', '825', '850',
        '875', '900', '925',
        '950', '975', '1000'
    ],
    'data_format': 'netcdf',
    'download_format': 'unarchived',
    'area': [50, 90, -10, 180]
}

client = cdsapi.Client()
client.retrieve(dataset, request, 'C:/Users/username/Desktop/clima_upper.nc').download()

I already had the latest python and cdsapi installed and the paths saved in the environment variables. I also have the “.cdsapirc” file stored in the "C:\Users\username" folder. As instructed, my “.cdsapirc” file contains:

url: https://cds.climate.copernicus.eu/api
key: <PERSONAL-ACCESS-TOKEN>

To prevent the “401 Client Error: Unauthorized” error, I used my User ID and API Token, thus formatting as “User ID:API Token”.

But, the Command Prompt returned the error messages “requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-pressure-levels” and “Exception: Not Found”:

I been searching for similar cases in the forum but many of them dealt with the CDS-Beta version which has be deprecated, so I can’t apply their troubleshoots. How do I fix this error? Could I have missed some steps or maybe I had done some mistakes along the way?

Brian

URL is now https://cds.climate.copernicus.eu/api/v2

Another thing you might also need to be aware of is that if you have instantaneous variables, such as temperature, and accumulated ones (e.g. solar radiation) two separate netcdf files are created, in which case you need to change download_format to ‘ZIP’. I don’t think this applies in you case.

Kind regards

Angus

https://cds.climate.copernicus.eu/api/v2

this new url also showing same error

The correct URL to use for the CDS in your .cdsapirc file is

https://cds.climate.copernicus.eu/api

as shown on CDSAPI setup - Climate Data Store

I have the same error as Brian. Accepted all licenses, using the correct URL in the .cdsapirc file and have the key as “USER ID”:“TOKEN KEY”.
What else to try?

Hi
please use the right credentials in your .cdsapirc file from here (please log in first): CDSAPI setup - Climate Data Store

Thanks

Hello,

I am having a similar issue to the one described by the OP. I have been trying the example given here https://cds.climate.copernicus.eu/how-to-api but am getting an error “404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-pressure-levels

I have cofigured by .cdsapirc correctly (with the key being in the form key=USER ID:TOKEN KEY) but have also tried specifying it in the client function with no luck. I am using the most up to date version of cdsapi (0.7.5)

Do you have any idea what might be going wrong?

Best wishes
Matt

import cdsapi
client = cdsapi.Client(url='https://cds.climate.copernicus.eu/api',key=key)

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)

Hi,
please use the link below for the right credentials.
The key doesn’t have the USER ID. That was the old template.

Hi Michela,

Thanks for the quick response - that works now, thanks very much!

Best wishes
Matt