{"id":9479,"library":"apimatic-requests-client-adapter","title":"APIMatic Requests Client Adapter","description":"`apimatic-requests-client-adapter` is a Python library that provides an adapter for the popular `requests` HTTP client library. It is specifically designed to be consumed by SDKs generated with APIMatic, allowing them to leverage `requests` for making HTTP calls while integrating APIMatic's configuration, retry logic, and other features. The library is actively maintained with a somewhat irregular but frequent release cadence, and its current version is 0.1.10.","status":"active","version":"0.1.10","language":"en","source_language":"en","source_url":"https://github.com/apimatic/requests-client-adapter","tags":["api-client","http-client","requests-adapter","sdk-generation","apimatic"],"install":[{"cmd":"pip install apimatic-requests-client-adapter","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core HTTP client library that this package adapts.","package":"requests"},{"reason":"Provides core utilities and configuration classes like `RequestsClientConfig` that are essential for configuring the adapter.","package":"apimatic-core"},{"reason":"Used for date parsing and formatting within APIMatic's ecosystem.","package":"python-dateutil"}],"imports":[{"note":"The `RequestsClient` class is located within the `requests_client` submodule, not directly under the top-level package.","wrong":"from apimatic_requests_client_adapter import RequestsClient","symbol":"RequestsClient","correct":"from apimatic_requests_client_adapter.requests_client import RequestsClient"},{"note":"While used by this adapter, `RequestsClientConfig` is part of `apimatic-core`, not this library itself.","symbol":"RequestsClientConfig","correct":"from apimatic_core.request_builders.requests_client_config import RequestsClientConfig"}],"quickstart":{"code":"from requests import Session\nfrom apimatic_core.request_builders.requests_client_config import RequestsClientConfig\nfrom apimatic_requests_client_adapter.requests_client import RequestsClient\n\n# 1. Configure the RequestsClient using RequestsClientConfig\n# This object defines behaviors like timeouts, retries, and proxy settings.\nclient_config = RequestsClientConfig(\n    timeout=30,\n    max_retries=3,\n    backoff_factor=0.5,\n    retry_status_codes=[408, 413, 429, 500, 502, 503, 504],\n    verify=True,\n    # Proxy support added in v0.1.8+\n    # proxies={'http': 'http://my.proxy.com:8080', 'https': 'https://my.proxy.com:8080'}\n)\n\n# 2. Optionally, create a pre-configured requests.Session object.\n# This allows sharing session state (like cookies) across requests.\nsession = Session()\n# You could configure the session further here, e.g., session.proxies = {'http': '...', 'https': '...'}\n\n# 3. Instantiate the RequestsClient adapter.\n# This client implements the IHttpClient interface expected by APIMatic SDKs.\n# If requests_session is not provided, an internal Session is created.\n# If client_config is not provided, default configurations are used.\nrequests_client_adapter = RequestsClient(\n    requests_client_config=client_config,\n    requests_session=session\n)\n\nprint(f\"APIMatic Requests Client Adapter created. Timeout: {requests_client_adapter._requests_client_config.timeout}s\")\n# This adapter is typically passed to an APIMatic-generated SDK client, e.g.:\n# my_sdk_client = MyAPISDKClient(http_client_instance=requests_client_adapter)","lang":"python","description":"This quickstart demonstrates how to instantiate the `RequestsClient` adapter. It involves creating a `RequestsClientConfig` object (from `apimatic-core`) to define HTTP client behavior and optionally a `requests.Session` for advanced session management. The `RequestsClient` instance is then ready to be passed into an APIMatic-generated SDK client."},"warnings":[{"fix":"Ensure you are using the `RequestsClient` as intended, typically by injecting it into an APIMatic-generated SDK client instance.","message":"This library is primarily an internal component for APIMatic-generated SDKs. While you can instantiate `RequestsClient` directly, its main purpose is to be passed as an `IHttpClient` interface implementation to an SDK client for making API calls. Direct standalone usage for raw HTTP requests is less common; for that, consider using the `requests` library directly.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to version 0.1.8 or newer and use the `proxies` dictionary parameter within `RequestsClientConfig` for straightforward proxy setup.","message":"Older versions (prior to 0.1.8) lacked first-class proxy support via the `RequestsClientConfig`. While proxies could be configured manually on a `requests.Session` object, direct configuration through the `client_config` was not available.","severity":"deprecated","affected_versions":"<0.1.8"},{"fix":"Upgrade to version 0.1.9 or newer. This version introduced support for passing a custom `requests.Session` object directly to `RequestsClient` or injecting a custom HTTP client instance via `http_client_instance` in `RequestsClientConfig`.","message":"Prior to version 0.1.9, injecting an arbitrary custom HTTP client or a pre-configured `requests.Session` directly through a defined interface was less flexible. This could complicate scenarios requiring highly customized HTTP client behavior beyond what `RequestsClientConfig` offered.","severity":"gotcha","affected_versions":"<0.1.9"},{"fix":"Consult the GitHub releases page or changelog for your specific versions before upgrading, paying close attention to any mentioned breaking changes or necessary migration steps.","message":"As a 0.x.x version library, minor version updates (e.g., 0.1.x to 0.2.x) can introduce breaking changes without strictly adhering to semantic versioning. Always review the GitHub release notes when updating across minor versions.","severity":"breaking","affected_versions":"All 0.x.x versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install apimatic-requests-client-adapter` to install the library.","cause":"The `apimatic-requests-client-adapter` library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'apimatic_requests_client_adapter'"},{"fix":"Upgrade both `apimatic-requests-client-adapter` and `apimatic-core` to their latest versions: `pip install --upgrade apimatic-requests-client-adapter apimatic-core`.","cause":"You are trying to use a configuration parameter (like `proxies` or `http_client_instance`) that was introduced in a newer version of `apimatic-requests-client-adapter` or `apimatic-core` with an older installed version.","error":"TypeError: RequestsClientConfig.__init__() got an unexpected keyword argument 'proxies'"},{"fix":"Run `pip install apimatic-core` to install the dependency.","cause":"The `apimatic-core` library, which provides the `RequestsClientConfig` class essential for configuring `RequestsClient`, is not installed.","error":"ModuleNotFoundError: No module named 'apimatic_core'"},{"fix":"Instantiate an APIMatic-generated SDK client and pass the `RequestsClient` instance to it. If you need raw `requests`-style functionality, use the `requests` library directly.","cause":"You are attempting to use the `RequestsClient` adapter directly like a `requests.Session` object to make HTTP requests. `RequestsClient` implements an `IHttpClient` interface and is meant to be passed to an APIMatic-generated SDK client, which then exposes the high-level API methods.","error":"AttributeError: 'RequestsClient' object has no attribute 'get'"}]}