I’m trying to talk to the API using a different language.
Is there a way to demonstrate how to talk to the API using CURL?
The knowledge base said:
Please note CDS API syntax is changed in the new system and some keys or parameter names may have also changed. Use the relevant dataset ‘Download Form’ to check the new syntax.
But I can’t seem to get it to work, and it directed me here.
For example
#!/bin/bash
# Set the API endpoint and parameters
API_URL="https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-single-levels"
API_KEY="API KEY" # Replace with your CDS API key
# Set the request parameters
REQUEST_PARAMS=$(cat <<EOF
{
"product_type": "reanalysis",
"variable": ["2m_temperature"],
"year": ["2022"],
"month": ["01"],
"day": ["01"],
"time": ["00:00"],
"format": "netcdf"
}
EOF
)
# Make the API request using curl
curl -X POST "$API_URL" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d "$REQUEST_PARAMS"
This returns:
{"message":"Not Found"}