Module implementing the main download client class

class*, redownload=False, raise_download_errors=True, config=None)[source]

Bases: object

A basic download client object

It does the following:

  • downloads the data with multiple threads in parallel,

  • handles any exceptions that occur during download,

  • decodes downloaded data,

  • reads and writes locally stored/cached data

  • redownload (bool) – If True the data will always be downloaded again. By default, this is set to False and the data that has already been downloaded and saved to an expected location will be read from the location instead of being downloaded again.

  • raise_download_errors (bool) – If True any error in download process will be raised as DownloadFailedException. If False failed downloads will only raise warnings.

  • config (Optional[SHConfig]) – An instance of configuration class

download(download_requests, max_threads=None, decode_data=True, show_progress=False)[source]

Download one or multiple requests, provided as a request list.

  • download_requests (Iterable[DownloadRequest]) – A list of requests to be executed.

  • max_threads (Optional[int]) – Maximum number of threads to be used for download in parallel. The default is max_threads=None which will use the number of processors on the system multiplied by 5.

  • decode_data (bool) – If True it will decode data otherwise it will return it in form of a DownloadResponse objects which contain binary data and response metadata.

  • show_progress (bool) – Whether a progress bar should be displayed while downloading


A list of results

Return type


get_json(url, post_values=None, headers=None, request_type=None, **kwargs)[source]

Download request as JSON data type

  • url (str) – A URL from where the data will be downloaded

  • post_values (Optional[Dict[str, Any]]) – A dictionary of parameters for a POST request

  • headers (Optional[Dict[str, Any]]) – A dictionary of additional request headers

  • request_type (Optional[RequestType]) – A type of HTTP request to make. If not specified, then it will be a GET request if post_values=None and a POST request otherwise

  • kwargs (Any) – Any other parameters that are passed to DownloadRequest class


JSON data parsed into Python objects

Return type

Optional[Union[Dict[str, Any], list, str]]

get_json_dict(url, *args, extract_key=None, **kwargs)[source]

Download request as JSON data type, failing if the result is not a dictionary

For other parameters see get_json method.

  • url (str) – A URL from where the data will be downloaded

  • extract_key (Optional[str]) – If provided, the field is automatically extracted, checked, and returned

  • args (Any) –

  • kwargs (Any) –

Return type

Dict[str, Any]

get_xml(url, **kwargs)[source]

Download request as XML data type

  • url (str) – url to Sentinel Hub’s services or other sources from where the data is downloaded

  • kwargs (Any) – Any other parameters that are passed to DownloadRequest class


request response as XML instance

Return type