Bundle Python API

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
s3455453
Posts: 1
Joined: Mon Sep 05, 2022 12:54 am America/New_York
Answers: 0

Bundle Python API

by s3455453 » Mon Sep 05, 2022 1:00 am America/New_York

Hello,

I am trying to get a list of files from the bundle API endpoint, so that I can can bulk download them instead of downloading each file one by one from the UI tasks page. My problem is the GET bundle/{task_id} endpoint does not seem to work, returning a 403 error. The bearer token seems to be correct, as I am able to perform other account based activities like submitting and listing tasks.

```
# List bundle
def list_bundle(task_id:str, headers:dict):
endpoint = f'https://appeears.earthdatacloud.nasa.gov/api/bundle/{task_id}'
r = requests.get(endpoint, headers)
if r.status_code not in range (200, 299):
return r.status_code, r.json()
return r.json()
```

```
list_bundle('bd5964fc-2812-4449-9a97-1913b1c2b05f', headers=headers)
```

Thanks

Tags:

LP DAAC - lien
User Services
User Services
Posts: 143
Joined: Thu Jun 25, 2020 9:51 am America/New_York
Answers: 0
Been thanked: 4 times

Re: Bundle Python API

by LP DAAC - lien » Tue Sep 13, 2022 12:49 pm America/New_York

Hi,
It looks like the code provided does not send the bearer token. Assuming that information is in the `headers` object, the `r = requests.get(endpoint,headers)` line needs to include `headers=headers` rather than in the call to the `list_bundle()` function.

For example:

token = token_response['token']

headers={'Authorization': 'Bearer {0}'.format(token)}

def list_bundle(task_id:str, headers:str):

endpoint = f'https://appeears.earthdatacloud.nasa.gov/api/bundle/{task_id}'

r = requests.get(endpoint, headers=headers)

if r.status_code not in range (200, 299):

return r.status_code, r.json()

return r.json()

list_bundle("bd5964fc-2812-4449-9a97-1913b1c2b05f ",headers)



Please refer to the current AρρEEARS API documentation for more details (https://appeears.earthdatacloud.nasa.gov/api/), and let us know if you have any other questions.

Regards,

The AρρEEARS Team

Post Reply