# API download 'target' not working

**URL:** <https://forum.ecmwf.int/t/api-download-target-not-working/5659>\
**Category:** C3S - Datasets and Usage\
**Tags:** era5\
**Created:** [17 September 2024 12:53 UTC](https://forum.ecmwf.int/t/api-download-target-not-working/5659 "2024-09-17T12:53:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Box](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/j/f6c823/32.png) [@Jason\_Box](https://forum.ecmwf.int/u/Jason_Box)\
**Post date:** [17 September 2024 12:53 UTC](https://forum.ecmwf.int/t/api-download-target-not-working/5659/1 "2024-09-17T12:53:48Z")

</div>

exciting that I am able to gather ERA5 data in the beta CDS using the following script, but the target=‘save\_to\_filename’ does not work. Instead, the downloaded file ends up in the python path from which the download script is run.

this is after updating to the cdsapi using $ pip install ‘cdsapi\>=0.7.0’

Anyone explain my issue?

script below

import cdsapi

dataset = “reanalysis-era5-single-levels-monthly-means”

```
request = {
    'product_type': ['monthly_averaged_reanalysis'],
    'variable': ['2m_temperature'],
    'year': [
        '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', '2016', '2017',
        '2018', '2019', '2020',
        '2021', '2022','2023','2024'],
    'month': ['06', '07', '08'],
    'time': ['00:00'],
    'data_format': 'grib',
    'download_format': 'unarchived',
    'area': [90, -180, 0, 180]
}

target = '/Users/jason/0_dat/ERA5/ERA5_t2m_1990-2024.grib'

```

---

<div class="post-metadata">

**Author:** ![Kevin\_Marsh](https://forum.ecmwf.int/user_avatar/forum.ecmwf.int/kevin_marsh/32/368_2.png) [@Kevin\_Marsh](https://forum.ecmwf.int/u/Kevin_Marsh)\
**Post date:** [17 September 2024 16:28 UTC](https://forum.ecmwf.int/t/api-download-target-not-working/5659/2 "2024-09-17T16:28:16Z")

</div>

hi, this worked for me (using cds api 0.7.3), running script in the ‘Downloads’ directory  
target=“/Downloads/test\_dir/test.grb”  
client.retrieve(dataset, request,target)

% ls -lt /Downloads/test\_dir  
total 395264  
-rw-r–r-- 1 - - 199352448 17 Sep 17:12 test.grb
