lothc
Lord Of The Http Clients — a typed HTTP client for Python, built on pyreqwest (a Rust-backed HTTP client), with first-class optional support for pydantic, msgspec, and TypedDict (validated via typeguard if installed) as decode targets.
from lothc import HTTPClient
from pydantic import BaseModel
class Pokemon(BaseModel):
id: int
name: str
async with HTTPClient.build(base_url="https://pokeapi.co/api/v2/") as client:
pikachu = await client.get("pokemon/pikachu", response_data_type=Pokemon)
print(pikachu) # id=25 name='pikachu'
Fast
Benchmarked with perf.py against a tiny Rust-based static JSON server, 10,000 requests at
concurrency 100 — including lothc's fully-typed decode targets (response_data_type= a msgspec
Struct, a pydantic BaseModel, or a TypedDict validated via typeguard), not just raw bytes or
an untyped dict. The object handed back from those runs isn't just parsed JSON — it's a real,
constructed, field-validated instance of your own type, and that validation cost is included in
the numbers, not benchmarked around. Decoding into a real msgspec Struct even edged out the
unvalidated dict path in this run; typeguard's pure-Python validation was the one clear exception,
costing a real, visible slowdown. Full numbers: docs/benchmarks.md.
Highlights
lothc's biggest offering over requests/httpx/aiohttp-and-friends: those clients hand you a
plain dict from .json() and leave validation to you. Pass response_data_type to any lothc
call and get back a real, constructed, field-validated pydantic BaseModel, msgspec Struct, or
typeguard-checked TypedDict instead — built in, not bolted on. See
Benchmarks for what that costs (usually nothing).
| Two clients, one API | HTTPClient (async) and SyncHTTPClient (sync) — identical surface, both backed by pyreqwest. |
| Every verb | get/get_result, post, put, patch, delete, head — see Verbs. |
| Typed params, headers & forms | A BaseModel/Struct for query params or headers (with None-field omission), or a real multipart body via form=. |
| Precise static types | Every verb is paired @overloads, not a cast-laden generic — your editor knows the exact return type. |
| SSE & streaming | Typed SSE decode (discriminated unions included), plus raw or NDJSON-typed stream_get/stream_post — see SSE / Streaming. |
| Retries with real backoff | max_retries/retry_methods, a genuine pyreqwest middleware hook, Retry-After-aware — see Retries. |
| Authentication | Static bearer_token, a per-request-refreshed bearer_auth, or default_headers for anything else — see Authentication. |
| Cookies, redirects, proxy | cookie_store, follow_redirects/max_redirects, proxy= — see Networking. |
| A real error hierarchy | HTTPTransportError/HTTPTimeoutError/HTTPConnectionError for no response, HTTPResponseError for 4xx/5xx — see Error handling. |
| Everything optional | pydantic, msgspec, typeguard — works with none, either, or all three installed. |
Installing
uv add 'lothc[pydantic,msgspec,typeguard]'
(Any subset of the extras works — the base package alone gets you bytes/JSON/TypedDict-without-validation support.)
Development
See CLAUDE.md and style-guide.md for architecture notes and the (non-obvious in places) design
conventions this codebase relies on.
task deps-sync # install
task test # run tests
task check # lint + format-check + typecheck (what CI runs)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lothc-0.0.3.tar.gz.
File metadata
- Download URL: lothc-0.0.3.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfb7e9dbdfd5cf1c533a16ac668b2cae0d04ee18d19303991038e12fe47a021e
|
|
| MD5 |
cc9fa00fab3a519215791a5dfccfb07d
|
|
| BLAKE2b-256 |
dc084c0310df43b7b3101d67cc41f27fff73a4fecdb22027a511a3b916673055
|
File details
Details for the file lothc-0.0.3-py3-none-any.whl.
File metadata
- Download URL: lothc-0.0.3-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5e42ec1164ae94bb1f8479047df8f4a6029cf174206059b49f6a25430453d59
|
|
| MD5 |
ae8b95f9070e23995cb60787bfbc1177
|
|
| BLAKE2b-256 |
dd7e1133bbd5d96596ea5d9fc5eb294a934807964d715b85b297e3f4a758a0ad
|