Metadata-Version: 2.4
Name: alt-stack-http-client-httpx
Version: 1.6.2
Summary: Asyncio HTTP client for alt-stack generated Pydantic SDKs, backed by httpx
License-Expression: MIT
Project-URL: Homepage, https://github.com/anthonyaltieri/alt-stack
Project-URL: Repository, https://github.com/anthonyaltieri/alt-stack
Project-URL: Issues, https://github.com/anthonyaltieri/alt-stack/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.7.0
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pyrefly>=1.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Requires-Dist: ty>=0.0.78; extra == "dev"
Dynamic: license-file

# `alt-stack-http-client-httpx`

Asyncio HTTP client for Python SDKs generated by `alt-stack-openapi-pydantic`. It is the Python counterpart of `@alt-stack/http-client-core` and `@alt-stack/http-client-fetch`: request inputs are validated and encoded with the SDK's `Request` map, responses are validated with its `Response` map, and results come back as a small discriminated union.

## Install

```bash
python -m pip install alt-stack-http-client-httpx
```

Generated SDK modules import `alt_stack_http_client_httpx` at runtime, so SDK consumers install this package. The generator itself is a development-time dependency.

## Use a generated SDK

```python
from alt_stack_http_client_httpx import ApiFailure, ApiSuccess

from generated_types import GetUsersIdParams, HttpxApiClient, Request, Response

async with HttpxApiClient(
    "https://api.example.com", request_map=Request, response_map=Response
) as client:
    result = await client.get("/users/{id}", params=GetUsersIdParams(id="u_1"))

if isinstance(result, ApiSuccess):
    result.body  # User
elif isinstance(result, ApiFailure):
    result.error  # documented error model
else:
    result.error  # UnexpectedApiClientError
```

Importing `HttpxApiClient` from the generated module gives one typed method per route. Importing it from `alt_stack_http_client_httpx` accepts the same arguments and exposes the untyped `request(method, path, ...)` API with runtime validation.

## Bring your own transport

`BaseApiClient` sends through the `Transport` protocol, a single `async def send(request: HttpRequest) -> HttpResponse`. Implement it over any asyncio HTTP library and pass it to the generated `ApiClient(base_url, transport=..., request_map=Request, response_map=Response)`.

## Development

```bash
uv run --project packages/python-http-client-httpx --extra dev pytest packages/python-http-client-httpx/tests
uv run --project packages/python-http-client-httpx --extra dev ruff check packages/python-http-client-httpx
uv run --project packages/python-http-client-httpx --extra dev ty check packages/python-http-client-httpx
```

## Documentation

- [Python/Pydantic API Documentation](../../apps/docs/docs/codegen/api/pydantic-openapi.md)
