Mastercard Places Python SDK
raw JSON → 1.0.6 verified Fri May 01 auth: no python
Official Mastercard Places API Python SDK. Provides access to Mastercard Places services. Version 1.0.6 (latest). Low release cadence.
pip install mastercard-places Common errors
error ModuleNotFoundError: No module named 'mastercard_places' ↓
cause Package name is mastercard-places, but import uses underscores.
fix
Ensure you have installed mastercard-places and are using import mastercard_places (with underscore).
error mastercard_places.exceptions.ApiException: (401) Unauthorized ↓
cause Invalid or missing authentication credentials (consumer key, keystore, etc.).
fix
Check your Mastercard developer credentials. Ensure environment variables are set correctly.
error AttributeError: 'NoneType' object has no attribute 'read' ↓
cause The keystore file path is invalid or the file cannot be read.
fix
Set KEYSTORE_PATH to the correct absolute path of the .p12 file and verify it exists.
Warnings
breaking The SDK assumes you are using a Mastercard developer account with valid PKCS12 keystore. Missing or malformed keystore leads to authentication failures. ↓
fix Use correct keystore file and password. Validate keystore path.
gotcha All API methods return raw dict or objects; errors are not raised as exceptions by default. Must check response status. ↓
fix Use try/except or check response.get('status') or use the SDK's error handling utilities (if any).
gotcha The SDK requires mastercard-core as a dependency but does not always pin a version. Conflicts can arise if installed separately. ↓
fix Install mastercard-places directly without manually installing mastercard-core; let pip resolve.
Imports
- PlacesApi wrong
from mastercard_places.places import PlacesApicorrectfrom mastercard_places import PlacesApi - ApiClient wrong
from mastercard_places.api_client import ApiClientcorrectfrom mastercard_places import ApiClient - Configuration wrong
from mastercard_places.configuration import Configurationcorrectfrom mastercard_places import Configuration
Quickstart
from mastercard_places import Configuration, ApiClient, PlacesApi
config = Configuration(
consumer_key=os.environ.get('CONSUMER_KEY', ''),
keystore_path=os.environ.get('KEYSTORE_PATH', ''),
keystore_password=os.environ.get('KEYSTORE_PASSWORD', ''),
key_alias=os.environ.get('KEY_ALIAS', ''),
host='https://api.mastercard.com')
client = ApiClient(config)
api = PlacesApi(client)
response = api.get_place_categories()
print(response)