Skip to content
GitHub

Quickstart

Install the package:

Terminal window
uv add lexigram-http
import asyncio
from 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())
import asyncio
from lexigram import Application
from 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())
  • HTTPModule.configure() registered HTTPClient as a container-managed singleton — bound to both HTTPClient and HTTPClientProtocol
  • 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
  • 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