{"id":2534,"library":"httpx-aiohttp","title":"Aiohttp Transport for HTTPX","description":"httpx-aiohttp provides an aiohttp-powered transport layer for HTTPX, allowing users to leverage aiohttp's robust asynchronous HTTP capabilities within the familiar HTTPX API. It is currently at version 0.1.12 and is actively maintained with frequent minor releases addressing compatibility and bug fixes.","status":"active","version":"0.1.12","language":"en","source_language":"en","source_url":"https://github.com/karpetrosyan/httpx-aiohttp","tags":["http client","async","aiohttp","httpx","transport","networking"],"install":[{"cmd":"pip install httpx-aiohttp","lang":"bash","label":"Install httpx-aiohttp"}],"dependencies":[{"reason":"Core HTTP client library that httpx-aiohttp extends for transport functionality.","package":"httpx"},{"reason":"Underlying asynchronous HTTP client providing the transport implementation.","package":"aiohttp"}],"imports":[{"note":"The primary class for integrating aiohttp as a transport for httpx.","symbol":"HttpxAiohttpTransport","correct":"from httpx_aiohttp import HttpxAiohttpTransport"}],"quickstart":{"code":"import asyncio\nimport httpx\nfrom httpx_aiohttp import HttpxAiohttpTransport\n\nasync def main():\n    # Initialize the aiohttp-powered transport\n    transport = HttpxAiohttpTransport()\n\n    # Create an httpx AsyncClient using the custom transport\n    async with httpx.AsyncClient(transport=transport) as client:\n        try:\n            response = await client.get(\"https://httpbin.org/get\")\n            response.raise_for_status() # Raise an exception for HTTP errors\n            print(f\"Status Code: {response.status_code}\")\n            print(f\"Response JSON: {response.json()}\")\n        except httpx.HTTPStatusError as e:\n            print(f\"HTTP error occurred: {e}\")\n        except httpx.RequestError as e:\n            print(f\"An error occurred while requesting: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"This example demonstrates how to create an `httpx.AsyncClient` that uses `HttpxAiohttpTransport` to perform an asynchronous GET request to `httpbin.org`."},"warnings":[{"fix":"Update authentication to use `httpx.BasicAuth('username', 'password')` instead of `('username', 'password')` tuple.","message":"When providing Basic Authentication credentials to `httpx.Client` or `httpx.AsyncClient`, passing a `(username, password)` tuple directly is deprecated in favor of using `httpx.BasicAuth`. This applies even when using `httpx-aiohttp` as the transport.","severity":"deprecated","affected_versions":"<0.1.10"},{"fix":"Upgrade to `httpx-aiohttp` version 0.1.9 or newer to ensure proper resource management.","message":"Versions prior to 0.1.9 might not properly close the underlying `aiohttp` response after reading content, potentially leading to resource leaks or unreleased connections in long-running applications.","severity":"gotcha","affected_versions":"<0.1.9"},{"fix":"Ensure you are using `httpx-aiohttp` version 0.1.12 or newer for full Python 3.8 compatibility.","message":"Early versions (prior to 0.1.11/0.1.12) had compatibility issues with Python 3.8, specifically related to the usage of the `|` operator for type hinting. Users on Python 3.8 might encounter syntax errors or unexpected behavior.","severity":"gotcha","affected_versions":"<0.1.12"},{"fix":"Upgrade to `httpx-aiohttp` version 0.1.8 or newer to ensure `Content-Type` is correctly omitted for empty GET requests.","message":"Versions prior to 0.1.8 might incorrectly include a `Content-Type` header in HTTP GET requests even when no request body is present. This could cause issues with servers that are strict about request header correctness.","severity":"gotcha","affected_versions":"<0.1.8"},{"fix":"Be aware that HTTP/2 is not supported when using this transport. If HTTP/2 is required, a different `httpx` transport or client may be necessary.","message":"The `aiohttp` library, which this transport leverages, does not inherently support HTTP/2. Therefore, when using `httpx-aiohttp`, any HTTP/2 features expected from a standard `httpx` client will not be available. The transport will revert to HTTP/1.1 communication.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}