{"id":24021,"library":"mastercard-api-core","title":"Mastercard API Python Core SDK","description":"Official Mastercard SDK for Python, providing core authentication, encryption, and HTTP client utilities for interacting with Mastercard APIs. Version 1.4.12 is the latest release; updates are periodic.","status":"active","version":"1.4.12","language":"python","source_language":"en","source_url":"https://github.com/Mastercard/mastercard-api-core-python","tags":["mastercard","sdk","api","payment","authentication"],"install":[{"cmd":"pip install mastercard-api-core","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"HTTP library used for API calls","package":"requests","optional":false},{"reason":"Cryptographic operations (OpenSSL wrapper)","package":"pycryptodomex","optional":false}],"imports":[{"note":"The correct package name is mastercard_api_core (with underscores), not mastercard.api.","wrong":"from mastercard.api import ApiConfig","symbol":"ApiConfig","correct":"from mastercard_api_core import ApiConfig"},{"note":"","wrong":"","symbol":"MasterCardApi","correct":"from mastercard_api_core import MasterCardApi"}],"quickstart":{"code":"import os\nfrom mastercard_api_core import ApiConfig, MasterCardApi\n\nconfig = ApiConfig(\n    consumer_key=os.environ.get('MASTERCARD_CONSUMER_KEY', ''),\n    key_file_path=os.environ.get('MASTERCARD_KEY_FILE_PATH', ''),\n    p12_path=os.environ.get('MASTERCARD_P12_PATH', '')\n)\napi = MasterCardApi(config)\n# Example: get a resource (generic, adjust per API)\nresponse = api.get('/api/v1/resource')\nprint(response.status_code, response.json())","lang":"python","description":"Initialize the SDK with a configuration object from environment variables and make an authenticated GET request."},"warnings":[{"fix":"Use 'pip install mastercard-api-core' and then 'import mastercard_api_core'.","message":"The package name on PyPI is 'mastercard-api-core', but the import uses underscores: 'mastercard_api_core'. Using hyphens in import will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.8 or higher.","message":"Support for Python 3.6 and 3.7 may be dropped in future versions; current version is tested on 3.8+.","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"Set 'p12_path' to the file path, not the base64 or string content.","message":"The SDK expects a .p12 file for mutual TLS authentication. Provide the path to the file, not the raw string content.","severity":"gotcha","affected_versions":"all"},{"fix":"Use keyword arguments: ApiConfig(consumer_key=..., key_file_path=..., p12_path=...).","message":"In version 1.4.0, the API client initialization changed from positional arguments to keyword arguments. Direct instantiation without keyword arguments will raise TypeError.","severity":"breaking","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change import to: from mastercard_api_core import ApiConfig","cause":"Importing using 'mastercard.api' instead of 'mastercard_api_core'.","error":"ImportError: No module named 'mastercard'"},{"fix":"Use keyword arguments: ApiConfig(consumer_key='...', ...)","cause":"Omitting required arguments or using only positional arguments (deprecated).","error":"TypeError: __init__() missing 1 required positional argument: 'consumer_key'"},{"fix":"Provide an absolute path to the .p12 file, e.g., os.path.abspath('mykey.p12').","cause":"The p12_path points to a file that does not exist or the path is relative from the wrong working directory.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'mykey.p12'"},{"fix":"Set environment variable REQUESTS_CA_BUNDLE to a PEM file, or use verify=False (not recommended for production).","cause":"Missing or invalid CA bundle or the server certificate is self-signed in test environment.","error":"requests.exceptions.SSLError: SSL: CERTIFICATE_VERIFY_FAILED"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}