sentinelhub.config

Module for managing configuration data from config.toml

class sentinelhub.config.SHConfig(profile=None, *, use_defaults=False, **kwargs)[source]

Bases: _SHConfig

A sentinelhub-py package configuration class.

The class reads the configurable settings from config.toml file on initialization:

  • instance_id: An instance ID for Sentinel Hub service used for OGC requests.

  • sh_client_id: User’s OAuth client ID for Sentinel Hub service. Can be set via SH_CLIENT_ID environment variable. The environment variable has precedence.

  • sh_client_secret: User’s OAuth client secret for Sentinel Hub service. Can be set via SH_CLIENT_SECRET environment variable. The environment variable has precedence.

  • sh_base_url: There exist multiple deployed instances of Sentinel Hub service, this parameter defines the location of a specific service instance.

  • sh_token_url: Url for Sentinel Hub Authentication service. Authentication is typically sent to the main service deployment even if sh_base_url points to another deployment.

  • geopedia_wms_url: Base url for Geopedia WMS services.

  • geopedia_rest_url: Base url for Geopedia REST services.

  • aws_access_key_id: Access key for AWS Requester Pays buckets.

  • aws_secret_access_key: Secret access key for AWS Requester Pays buckets.

  • aws_session_token: A session token for your AWS account. It is only needed when you are using temporary credentials.

  • aws_metadata_url: Base url for publicly available metadata files

  • aws_s3_l1c_bucket: Name of Sentinel-2 L1C bucket at AWS s3 service.

  • aws_s3_l2a_bucket: Name of Sentinel-2 L2A bucket at AWS s3 service.

  • opensearch_url: Base url for Sentinelhub Opensearch service.

  • max_wfs_records_per_query: Maximum number of records returned for each WFS query.

  • max_opensearch_records_per_query: Maximum number of records returned for each Opensearch query.

  • max_download_attempts: Maximum number of download attempts from a single URL until an error will be raised.

  • download_sleep_time: Number of seconds to sleep between the first failed attempt and the next. Every next attempt this number exponentially increases with factor 3.

  • download_timeout_seconds: Maximum number of seconds before download attempt is canceled.

  • number_of_download_processes: Number of download processes, used to calculate rate-limit sleep time.

  • max_retries: Maximum number of retries until an exception is raised.

The location of config.toml for manual modification can be found with SHConfig.get_config_location().

Parameters:
  • profile (str | None) – Specifies which profile to load from the configuration file. Has precedence over the environment variable SH_USER_PROFILE.

  • use_defaults (bool) – Does not load the configuration file, returns config object with defaults only.

  • kwargs (Any) – Any fields of SHConfig to be updated. Overrides settings from config.toml and environment.

CREDENTIALS = ('instance_id', 'sh_client_id', 'sh_client_secret', 'aws_access_key_id', 'aws_secret_access_key', 'aws_session_token')
classmethod load(profile=None)[source]

Loads configuration parameters from the config file at SHConfig.get_config_location().

Parameters:

profile (str | None) – Which profile to load from the configuration file.

Return type:

SHConfig

save(profile=None)[source]

Saves configuration parameters to the config file at SHConfig.get_config_location().

Parameters:

profile (str | None) – Under which profile to save the configuration.

Return type:

None

copy()[source]

Makes a copy of an instance of SHConfig

Return type:

SHConfig

to_dict(mask_credentials=True)[source]

Get a dictionary representation of the SHConfig class.

Parameters:

mask_credentials (bool) – Wether to mask fields containing credentials.

Returns:

A dictionary with configuration parameters

Return type:

dict[str, str | float]

classmethod get_config_location()[source]

Returns the default location of the user configuration file on disk.

Return type:

str