Registry /
http-networking / apimatic-core-interfaces
Install & Compatibility
Where this runs
tested against v0.1.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
IHttpClient
✓ from apimatic_core_interfaces.types.http.http_client import IHttpClient
✗ from apimatic_core_interfaces import IHttpClient
This example demonstrates how to implement the `IHttpClient` interface, which is a common requirement when extending or customizing APIMatic SDK behavior. It defines a `CustomHttpClient` class that fulfills the `send` and `convert_response` abstract methods. In a real application, the `send` method would perform an actual HTTP request, and `convert_response` would adapt the underlying library's response object to `apimatic_core_interfaces.client.http.HttpResponse`.
import abc
from apimatic_core_interfaces.client.http.http_client import IHttpClient
from apimatic_core_interfaces.client.http.request import HttpRequest
from apimatic_core_interfaces.client.http.response import HttpResponse
from apimatic_core_interfaces.client.http.http_context import HttpContext
from typing import Any # Used for type hinting a generic raw response
class CustomHttpClient(IHttpClient):
"""
A minimal custom HTTP client implementation demonstrating how to fulfill
the apimatic-core-interfaces. It shows how to implement the required methods.
This class would typically wrap an existing HTTP library like `requests` or `httpx`.
"""
def send(self, request: HttpRequest, context: HttpContext = None) -> HttpResponse:
print(f"CustomHttpClient received request for: {request.query_url}")
# Simulate a raw response object/dictionary from an underlying HTTP client.
# In a real scenario, this would involve making an actual HTTP call.
raw_response_mock = {
'status_code': 200,
'reason_phrase': 'OK',
'headers': {'Content-Type': 'application/json'},
'text': '{"message": "Hello from custom client!"}',
'request_method': request.method,
'request_url': request.query_url
}
# Convert the raw response using the provided interface method
return self.convert_response(raw_response_mock)
def convert_response(self, raw_response: Any) -> HttpResponse:
"""
Converts a raw HTTP client response (e.g., from `requests`, `httpx`, or a mock)
into an `HttpResponse` object as expected by APIMatic Core.
"""
return HttpResponse(
status_code=raw_response.get('status_code', 200),
reason_phrase=raw_response.get('reason_phrase', 'OK'),
headers=raw_response.get('headers', {}),
body=raw_response.get('text', ''),
request=HttpRequest(
method=raw_response.get('request_method', 'GET'),
path=raw_response.get('request_url', '/'),
query_url=raw_response.get('request_url', '/')
)
)
# Example of how to use this custom client (uncomment to run):
# my_custom_client = CustomHttpClient()
# sample_request = HttpRequest(
# method='GET',
# path='/api/data',
# query_url='https://api.example.com/api/data',
# headers={'Accept': 'application/json'}
# )
# response = my_custom_client.send(sample_request)
# print(f"\nCustom client got response - Status: {response.status_code}, Body: {response.body}")
Debug
Known issues
breakingAdding new abstract methods to existing interfaces (e.g., `IHttpClient`, `ILogger`) in minor version updates can break custom implementations that inherit from these interfaces but do not implement the newly added methods.fixAlways check release notes for new abstract methods when upgrading and ensure all custom implementations are updated accordingly. Consider pinning to exact minor versions for production.
affects: 0.x.x (prior to 1.0.0)
gotchaAttempting to instantiate an APIMatic interface (which are Python Abstract Base Classes) directly will result in a `TypeError`.fixInterfaces must be inherited by a concrete class, and all their abstract methods must be implemented before the concrete class can be instantiated. For example, `client = CustomHttpClient()` is correct, `client = IHttpClient()` is wrong.
affects: All versions
gotchaA concrete class inheriting from an APIMatic interface must implement *all* abstract methods defined by that interface. Failing to do so will prevent the concrete class from being instantiated.fixEnsure your custom implementation class defines and implements every method marked as abstract in the interface it inherits from (e.g., `send` and `convert_response` for `IHttpClient`). The Python interpreter will raise a `TypeError` if any are missing.
affects: All versions
Upgrade
Version history
0.1.8latest on PyPI · released Oct 29, 2025
Audit
Dependencies
No dependency data recorded yet.