download.client

Module implementing the main download client class

class sentinelhub.download.client.DownloadClient(*, 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
Parameters:
  • 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 (SHConfig) – An instance of configuration class
download(download_requests, max_threads=None, decode_data=True)[source]

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

Parameters:
  • download_requests (List[DownloadRequest] or DownloadRequest) – A list of requests or a single request to be executed.
  • max_threads (int or None) – 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 binary format.
Returns:

A list of results or a single result, depending on input parameter download_requests

Return type:

list(object) or object

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

Download request as JSON data type

Parameters:
  • url (str) – An URL from where the data will be downloaded
  • post_values (dict or None) – A dictionary of parameters for a POST request
  • headers (dict) – A dictionary of additional request headers
  • request_type (RequestType or None) – 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 other parameters that are passed to DownloadRequest class
Returns:

JSON data parsed into Python objects

Return type:

dict or list or str or None

get_xml(url, **kwargs)[source]

Download request as XML data type

Parameters:
  • url (str) – url to Sentinel Hub’s services or other sources from where the data is downloaded
  • kwargs – Any other parameters that are passed to DownloadRequest class
Returns:

request response as XML instance

Return type:

XML instance or None

sentinelhub.download.client.get_json(url, post_values=None, headers=None, request_type=None, download_client_class=<class 'sentinelhub.download.client.DownloadClient'>, **kwargs)[source]

Download request as JSON data type

Parameters:
  • url (str) – An URL from where the data will be downloaded
  • post_values (dict or None) – A dictionary of parameters for a POST request
  • headers (dict) – A dictionary of additional request headers
  • request_type (RequestType or None) – 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
  • download_client_class (object) – A class that implements a download client
  • kwargs – Parameters that are passed to a DownloadRequest class
Returns:

JSON data parsed into Python objects

Return type:

object or None

sentinelhub.download.client.get_xml(url, download_client_class=<class 'sentinelhub.download.client.DownloadClient'>)[source]

Download request as XML data type

Parameters:
  • url (str) – url to Sentinel Hub’s services or other sources from where the data is downloaded
  • download_client_class (object) – A class that implements a download client
Returns:

request response as XML instance

Return type:

XML instance or None

Raises:

RunTimeError