SentinelAPI Error InvalidKeyException

I am querying the S3 Open Access Hub using SentinelAPI to get a list of frames, but encounter a problem when trying to access products using the key that results from api.query.

This is my code:

from sentinelsat import SentinelAPI
api = SentinelAPI(username,password,'')
products=api.query(footprint=(-16.108,128.749), date=('20190101','NOW'), producttype='SY_2_SYN___', cloudcoverpercentage=(0,50))
with open(outTXT,'w') as f:
     for n in range(len(productlist)):

At some point, an error is raised:

raise api_error
SentinelAPIError: InvalidKeyException : Invalid key (f0ac893b-7b5c-438b-8657-b28607e65b9b) to access Products

I have run this type of code for other footprints without any problem.
How can I solve this? Thanks!

I have checked the Copernicus Open Access Hub. It appears that one frame (the one acquired on 20190811) is missing, while it was retrieved by the api.query:


Although the search result says "Display 1 to 3 of 3 products, only 2 products are available for download (see screenshot below)… How can I avoid this error being raised?

What do you think, if adding up raise Exception, in case any date is missing like this case.

Also in this case remove NOW and add up the date before the missed one, and take a look if it gives any sense!

Also put in mind that some dates are offline,

Hi falahfakhri,

Thanks. Yes, changing the date in they query will solve this case.
The problem is that I need to perform this query for a large number of sites and would like to avoid having to fix this manually each time an error is raised.
I do not understand why the query returns more keys than actually available for download.

Might be separate the dates to some parts and run your code could solve the problem, for instance each three months, in this case could avoiding and knowing before hand the missed dates to retrieve them later, and you don’t need to manually edit the code every now and then.

I changed the API into

from sentinelsat import SentinelAPI
api = SentinelAPI(username,password,'')

No more errors are raised. :slight_smile: