# Issues using the CDS API in Python

**URL:** <https://forum.ecmwf.int/t/issues-using-the-cds-api-in-python/6813>\
**Category:** CAMS - Datasets and Usage\
**Tags:** cams, api, access, cds, cams\_global\_forecast\
**Created:** [11 October 2024 14:28 UTC](https://forum.ecmwf.int/t/issues-using-the-cds-api-in-python/6813 "2024-10-11T14:28:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Ankerstjerne](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/c/e47c2d/32.png) [@Christian\_Ankerstjerne](https://forum.ecmwf.int/u/Christian_Ankerstjerne)\
**Post date:** [11 October 2024 14:28 UTC](https://forum.ecmwf.int/t/issues-using-the-cds-api-in-python/6813/1 "2024-10-11T14:28:07Z")

</div>

To whom it may concern.

I am currently trying to access the CDS API via python and having issues. I am running the following code:

```auto
dataset = "cams-global-atmospheric-composition-forecasts"
request = {
    "variable": [
        "10m_u_component_of_wind",
        "10m_v_component_of_wind"
    ],
    "date": ["2024-01-01/2024-01-07"],
    "time": ["12:00"],
    "leadtime_hour": [str(x) for x in range(0, 121, 1)],
    "type": ["forecast"],
    "data_format": "netcdf_zip",
    "area": [56, 7, 55, 8]
}

client = cdsapi.Client()
client.retrieve(dataset, request)

```

I have cdsapi==0.7.3 installed and I have put my API key credentials in $HOME/.cdsapi. I get the following error code when trying to run the above:

```auto
HTTPError: 404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/retrieve/v1/jobs/d3116eef-2144-4be6-be11-5f77a46f4733?log=True&request=True
job not found
job d3116eef-2144-4be6-be11-5f77a46f4733 not found

```

Despite this error, when I go to the web interface here: [Atmosphere Data Store](https://ads.atmosphere.copernicus.eu/requests?tab=all), I see the request and it downloads successfully. However, I wish to be able to download and treat the data through the API.

I hope you clever guys can figure this out! Thank you 🙂

---

<div class="post-metadata">

**Author:** ![Koen\_Hufkens](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/koen_hufkens/32/526_2.png) [@Koen\_Hufkens](https://forum.ecmwf.int/u/Koen_Hufkens)\
**Post date:** [11 October 2024 21:10 UTC](https://forum.ecmwf.int/t/issues-using-the-cds-api-in-python/6813/2 "2024-10-11T21:10:32Z")

</div>

The CDS and ADS endpoints are different, this causes the error. Sadly and confusingly so, they are set by the same file. Meaning you have to switch between them using session variables. A solution is provided here. Note that this exposes your key. I think you can just set the url, but you should cross reference the source code or ask the devs.

> [@Is there elsewhere to put the .cdsapirc file? Running it on Databricks](https://prod.ecmwf-forum-prod.compute.cci2.ecmwf.int/t/is-there-elsewhere-to-put-the-cdsapirc-file-running-it-on-databricks/956):
>
> Hi everyone, I am trying to extract ERA5 data on Databricks. It turns out that the home path (home/) is not available in Databricks because I don't have access right to it. So, is there any way that I can manage to use my cdsapi and extract data in Databricks?

Reading along the source code of the python package here:

> <https://github.com/ecmwf/cdsapi/blob/9b162d6b093b80283a672203b384c2a67cb35a8b/cdsapi/api.py#L48>

You see that you can set the url and key separate.

Keep you key in your .cdsapirc file only change the url using:

```auto
os.environ['CDSAPI_URL'] = 'https://ads.atmosphere.copernicus.eu/api'

```

---

<div class="post-metadata">

**Author:** ![Christian\_Ankerstjerne](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/c/e47c2d/32.png) [@Christian\_Ankerstjerne](https://forum.ecmwf.int/u/Christian_Ankerstjerne)\
**Post date:** [12 October 2024 12:10 UTC](https://forum.ecmwf.int/t/issues-using-the-cds-api-in-python/6813/3 "2024-10-12T12:10:51Z")

</div>

Aha, this is very clear, thank you! And I see that this approach (as specified in the other post) also does not disclose my key. It solved my problem, very smart 🙂
