Skip to content

Implement async HTTP client wrapper using httpx #8

Description

@codebestia

Description

An async counterpart to the sync client using httpx.AsyncClient, enabling use in async frameworks like FastAPI, Starlette, and Django async views. It should share the same configuration and interface as the sync client so resource methods can delegate to either with minimal branching.

Proposed Steps

  • Add _AsyncHTTPClient to http_client.py, mirroring the sync interface with async def request(...).
  • Accept the same constructor arguments as _SyncHTTPClient.
  • Use async with httpx.AsyncClient(...) as client lifecycle management.
  • Extract a shared _build_request(method, path, params, json) helper used by both sync and async versions.

Acceptance Criteria

  • await client.request("GET", "/payments") returns the same response shape as the sync version.
  • The async client can be used in a pytest-asyncio test without event loop conflicts.
  • Closing the async client (via aclose()) is properly awaited.
  • Sync and async clients share URL-building and header logic without duplication.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions