Skip to main content

lothc logo

lothc

CI Python 3.13+

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

HTTP client throughput race — lothc and pyreqwest finish in well under a fifth of a second, other libraries take much longer

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

lothc-0.0.1.tar.gz (420.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lothc-0.0.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file lothc-0.0.1.tar.gz.

File metadata

  • Download URL: lothc-0.0.1.tar.gz
  • Upload date:
  • Size: 420.5 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

Hashes for lothc-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8229a9d4ebd3f41b7cea1dd4a4dec5f53dff87821fcc87af73099c5c61acc3e8
MD5 84d02626b833dd2e187f45df607060e9
BLAKE2b-256 97badd97e88c93b7b627267376e4daef82559170ab47ee55caa07ade6c74a74c

See more details on using hashes here.

File details

Details for the file lothc-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lothc-0.0.1-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

Hashes for lothc-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef0a01f09b98584ff5e586520738311c8afea491d62b3ae77240c88d6eda1a9d
MD5 8716e933635c3dfc592f218b4c42b4a1
BLAKE2b-256 c08fa9946e67903cbc890d55b96e857bdf9be873841210f55f51410176fac093

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page