Mastercard Merchant Identifier

raw JSON →
2.0.0 verified Fri May 01 auth: no python

Mastercard Merchant Identifier API Python SDK for retrieving merchant information. Version 2.0.0. Release cadence irregular, tied to API updates.

pip install mastercard-merchant-identifier
error ModuleNotFoundError: No module named 'mastercard_merchant_identifier.client'
cause Tried to import from the old module path used in version 1.x.
fix
Use from mastercard_merchant_identifier.rest import MerchantIdentifierApi
error ImportError: cannot import name 'ApiClient' from 'mastercard_merchant_identifier'
cause ApiClient is not part of this SDK; it's in mastercard-api-common.
fix
pip install mastercard-api-common and use from mastercard_api_common import ApiClient
error AttributeError: 'NoneType' object has no attribute 'get'
cause ApiClient initialization failed due to missing or invalid credentials. Often happens when signing key path or consumer key is not set.
fix
Verify environment variables MASTERCARD_CONSUMER_KEY, MASTERCARD_KEY_ALIAS, MASTERCARD_SIGNING_KEY_PATH are correct and the signing key file is accessible.
breaking Version 2.0.0 changed import paths and removed the old mastercard_merchant_identifier.client module. Code written for v1.x will not work.
fix Update imports to use mastercard_merchant_identifier.rest and mastercard-api-common for ApiClient.
gotcha The ApiClient class is not in this package; it's in mastercard-api-common. You must install and import from that separate package.
fix pip install mastercard-api-common and import ApiClient from mastercard_api_common.
deprecated The method 'get_merchant_identifiers' may return a dictionary, not a response object. Check the official docs for exact return type.
fix Inspect response or rely on API reference.
gotcha Environment variables for authentication must be set explicitly; the SDK does not use .env files automatically.
fix Set MASTERCARD_CONSUMER_KEY, MASTERCARD_KEY_ALIAS, MASTERCARD_SIGNING_KEY_PATH (or equivalently use PKCS12 keystore).
gotcha The Sandbox vs Production environment is controlled by a boolean parameter in ApiClient; make sure to set sandbox=False for production.
fix Use ApiClient(..., sandbox=False) for production.

Quickstart using environment variables for credentials and sandbox.

import os
from mastercard_api_common import ApiClient
from mastercard_merchant_identifier.rest import MerchantIdentifierApi

consumer_key = os.environ.get('MASTERCARD_CONSUMER_KEY', '')
key_alias = os.environ.get('MASTERCARD_KEY_ALIAS', '')
signing_key_path = os.environ.get('MASTERCARD_SIGNING_KEY_PATH', '')

api_client = ApiClient(consumer_key, key_alias, signing_key_path, sandbox=True)
api = MerchantIdentifierApi(api_client)
response = api.get_merchant_identifiers(merchant_id='123456')
print(response)