The magento
Package
The magento
package provides various tools to help simplify interaction with the Magento 2 API.
Functions
-
magento.get_api(**kwargs)View on GitHub
View Source Code
def get_api(**kwargs) -> Client: """Initialize a :class:`~.Client` using credentials stored in environment variables Any valid :class:`~.Client` kwargs can be used in addition to and/or instead of environment variables **Usage**:: import magento api = magento.get_api() :param kwargs: any valid kwargs for :class:`~.Client` :raises ValueError: if login credentials are missing """ credentials = { 'domain': kwargs.get('domain', os.getenv('MAGENTO_DOMAIN')), 'username': kwargs.get('username', os.getenv('MAGENTO_USERNAME')), 'password': kwargs.get('password', os.getenv('MAGENTO_PASSWORD')), 'local': kwargs.get('local', False), } if bad_keys := [key for key in credentials if credentials[key] is None]: raise ValueError(f'Missing login credentials for {bad_keys}') else: return Client.from_dict(credentials) Initialize a
Client
using credentials stored in environment variablesAny valid
Client
kwargs can be used in addition to and/or instead of environment variablesUsage:
import magento api = magento.get_api()
- Parameters
kwargs – any valid kwargs for
Client
- Raises
ValueError – if login credentials are missing
- Return type
…
…