Retrieving data for analysis in Google Colabs

Hello everyone,

I am new to the CDS and as the system is getting some changes between the previous page to the beta-CDS page, I got confused when looking at some tutorials. I have a problem retrieving data in Google Colabs. Here is the code

!pip install cdsapi netCDF4 xarray
!pip install --upgrade cdsapi
import cdsapi
client = cdsapi.Client(url=‘https://cds-beta.climate.copernicus.eu/api’, key=‘<d9999229-898a-…>’)
dataset = “reanalysis-era5-single-levels”
request = {
‘product_type’: ‘reanalysis’,
‘variable’: [‘10m_u_component_of_wind’, ‘10m_v_component_of_wind’, ‘100m_u_component_of_wind’, ‘100m_v_component_of_wind’],
‘year’: [‘2023’],
‘month’: [‘01’, ‘02’, ‘03’, ‘04’, ‘05’, ‘06’, ‘07’, ‘08’, ‘09’, ‘10’, ‘11’, ‘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’, ‘01:00’, ‘02:00’, ‘03:00’, ‘04:00’, ‘05:00’, ‘06:00’, ‘07:00’, ‘08:00’, ‘09:00’, ‘10:00’, ‘11:00’, ‘12:00’, ‘13:00’, ‘14:00’, ‘15:00’, ‘16:00’, ‘17:00’, ‘18:00’, ‘19:00’, ‘20:00’, ‘21:00’, ‘22:00’, ‘23:00’],
‘format’: ‘grib’
}
client.retrieve(dataset, request, ‘download.grib’)

I always get the RuntimeError: 401 Client Error: Authentication failed
operation not allowed

I have already checked to accept all the terms of use as suggested in some recent topics on the forum, but it’s still not solved. I found my API key in Your Profile > Personal Access Token. I am not sure about the url, I tried “https://cds-beta.climate.copernicus.eu/api” and “https://cds-beta.climate.copernicus.eu/api/v2” and they both don’t work.
I don’t know what else I should check.
Thank you in advance for all of your help and responses!!!

Hi, you can go to the page like : https://cds-beta.climate.copernicus.eu/datasets/reanalysis-era5-pressure-levels?tab=download, and then scroll down to the bottom of the page, you will see “Terms of use”

This sounds amazing as I found it very much useful and informative to be honest. Also, I have gone through this post which definitely helped me out a lot as a new member I am looking forward for more such discussions. :slightly_smiling_face: