Quickstart
Install the package:
uv add lexigram-httpMinimal example (standalone)
Section titled “Minimal example (standalone)”import asynciofrom lexigram.http import HTTPClient
async def main() -> None: async with HTTPClient.session_context() as client: response = await client.get("https://api.example.com/health") if response.ok: data = await response.json() print(f"Status: {data}")
asyncio.run(main())Via DI
Section titled “Via DI”import asynciofrom lexigram import Applicationfrom lexigram.http import HTTPModule
async def main() -> None: app = Application(name="my-app") app.add_module(HTTPModule.configure()) async with Application.boot(name="my-app", modules=[HTTPModule.configure()]) as app: from lexigram.contracts.web import HTTPClientProtocol
client = await app.container.resolve(HTTPClientProtocol) response = await client.get("https://api.example.com/health") if response.ok: print("API is healthy")
asyncio.run(main())What just happened
Section titled “What just happened”HTTPModule.configure()registeredHTTPClientas a container-managed singleton — bound to bothHTTPClientandHTTPClientProtocol- The connection pool was configured with defaults (10 max connections, 30s timeout, DNS cache TTL 300s)
- The resolved client made a GET request and returned an
HttpResponse
Next steps
Section titled “Next steps”- Guide — connection pooling, interceptors, resilience, streaming
- Architecture — provider, contracts, pool, retry, circuit breaker
- Configuration — pool config, proxy, timeouts, cookie jar
- How-Tos — custom headers, retry policy, streaming, base URL client