{"id":8835,"library":"apimatic-core","title":"APIMatic Core Library for Python","description":"APIMatic Core is a foundational Python library (v0.2.24) that provides the essential logic and utilities for consuming REST APIs. It's primarily used as a dependency for Python SDKs generated by APIMatic, aiming to offer a consistent and robust developer experience. The library receives frequent minor updates, focusing on new features, bug fixes, and dependency bumps.","status":"active","version":"0.2.24","language":"en","source_language":"en","source_url":"https://github.com/apimatic/core-lib-python","tags":["api","sdk","codegen","http-client","rest","core-library"],"install":[{"cmd":"pip install apimatic-core","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Utility for date and time parsing.","package":"python-dateutil","optional":false},{"reason":"Serialization and deserialization of complex Python objects to and from JSON.","package":"jsonpickle","optional":false},{"reason":"HTTP client for making API calls.","package":"requests","optional":false}],"imports":[{"note":"Used to modify global settings for generated SDKs.","symbol":"GlobalConfiguration","correct":"from apimatic_core.configurations.global_configuration import GlobalConfiguration"},{"note":"Base exception class for API-specific errors.","symbol":"ApiException","correct":"from apimatic_core.exceptions.api_exception import ApiException"},{"note":"Contains utility functions for API requests and responses.","symbol":"ApiHelper","correct":"from apimatic_core.utilities.api_helper import ApiHelper"}],"quickstart":{"code":"import os\nfrom apimatic_core.configurations.global_configuration import GlobalConfiguration\nfrom apimatic_core.http.requests_client.requests_client import RequestsClient\n\n# This library is primarily used by generated SDKs. \n# Direct usage often involves configuring global settings \n# or handling generic exceptions.\n\n# Example: Configure global HTTP client settings\nGlobalConfiguration.set_timeout(30) # seconds\nGlobalConfiguration.set_user_agent(\"MyCustomApp/1.0\")\nGlobalConfiguration.set_verify_ssl(True)\n\n# Optionally provide a custom HTTP client instance\n# GlobalConfiguration.set_http_client(RequestsClient())\n\nprint(f\"Global API Timeout: {GlobalConfiguration.get_timeout()} seconds\")\nprint(f\"Global User-Agent: {GlobalConfiguration.get_user_agent()}\")\nprint(f\"Global SSL Verification: {GlobalConfiguration.get_verify_ssl()}\")\n\n# In a generated SDK, these settings would now apply.\n# For example, if you had an SDK generated by APIMatic:\n# from my_generated_sdk.client import MyClient\n# client = MyClient()\n# ... the client would use the configured settings\n\n# Example for handling a generic API exception (would typically come from a generated SDK call)\ntry:\n    # Simulate an operation that might raise an ApiException\n    raise ApiException(\"Resource not found\", 404, {'X-Request-ID': 'abc'})\nexcept ApiException as e:\n    print(f\"Caught API Exception: {e.message} (Status: {e.response_code})\")\n    print(f\"Headers: {e.response_headers}\")\n","lang":"python","description":"This quickstart demonstrates how to configure global settings that would be utilized by an APIMatic-generated SDK. It also shows how to catch a generic `ApiException`, a common pattern when working with generated clients."},"warnings":[{"fix":"Understand that direct usage is for advanced customization or debugging of generated SDKs. For general HTTP client needs, consider `requests`.","message":"APIMatic Core is primarily an internal library for SDKs generated by APIMatic. While you can import and use its components directly, its main purpose is to provide a consistent base for generated code. If you're not using APIMatic to generate an SDK, you might find more direct HTTP client libraries (like `requests`) more suitable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using Python 3.8+ for optimal compatibility. Upgrade to a supported Python version if encountering compatibility errors.","message":"Older versions of Python might not be fully supported. While `apimatic-core` aims for broad compatibility, recent releases (v0.2.18+) explicitly test for Python 3.12 and 3.13. Using significantly older Python versions (e.g., Python 3.7 or earlier) may lead to unexpected issues.","severity":"deprecated","affected_versions":"<0.2.18 (potentially)"},{"fix":"For highly specific client configurations, consider creating and passing a custom `RequestsClient` instance to the generated SDK's client constructor if supported, rather than relying solely on global settings.","message":"Modifying `GlobalConfiguration` directly affects *all* subsequent operations that use these global settings within your application's process. Be mindful of potential side effects, especially in multi-threaded environments or if different parts of your application require distinct API configurations.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install apimatic-core` to install the library.","cause":"The `apimatic-core` library is not installed in your Python environment.","error":"ModuleNotFoundError: No module named 'apimatic_core'"},{"fix":"Most user-level interactions are with concrete implementations like `RequestsClient` or higher-level abstractions like `GlobalConfiguration` and `ApiException`. Consult the library's source code or a generated SDK's usage for specific concrete classes.","cause":"Attempting to import an abstract base class or an internal implementation that is not directly exposed or intended for direct instantiation.","error":"from apimatic_core.http.http_client import HttpClient # or similar import fails"},{"fix":"Ensure that the base URL configured for your generated SDK (or passed to any core HTTP client method) includes a valid scheme. Check your SDK's configuration or environment variables.","cause":"Often occurs when the base URL for an API call (usually set by a generated SDK) is misconfigured or missing a scheme (e.g., `http://` or `https://`). `apimatic-core` relies on `requests` which requires a valid URL.","error":"ValueError: Invalid URL: No scheme supplied. Perhaps you meant http://..."}]}