New in version 0.2.6.
There is a growing list of configuration options for the library, many of which can be passed directly to the API constructor at initialisation. Some options, such as credentials, can also be read from environment variables (e.g. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY).
To use a config file, pass its path to the API:
import amazonproduct
api = amazonproduct.API(cfg='~/my-config-file')
If no path was specified, the API looks for configuration files in the following locations and in the following order:
The options are merged into a single, in-memory configuration that is available.
The following sections and options are currently recognized within the config file.
The Credentials section is used to specify the AWS credentials used for all requests.
Example:
[Credentials]
access_key = <your access key>
secret_key = <your secret key>
associate_tag = <your associate id>
Note
Stating the obvious: Your access key is not <your access key> but something like 10RZZJBK6YBQASX213G2.
If you need to configure the API at runtime you can also pass the config values as dict:
import amazonproduct
config = {
'access_key': 'ABCDEFG1234X',
'secret_key': 'Ydjkei78HdkffdklieAHDJWE3134',
'associate_tag': 'redtoad-10',
'locale': 'us'
}
api = amazonproduct.API(cfg=config)
You can also set the following environment variables:
Important
Environment variables will always take precedence over values from config files but not from config dict!
The following table gives an overview which values can be defined where:
config file | environment variable |
---|---|
access_key | AWS_ACCESS_KEY_ID |
secret_key | AWS_SECRET_ACCESS_KEY |
associate_tag | AWS_ASSOCIATE_TAG |
locale | AWS_LOCALE |