Skip to main content

lothc logo

lothc

PyPI CI codecov Python versions License

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.2.tar.gz (15.6 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.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lothc-0.0.2.tar.gz
  • Upload date:
  • Size: 15.6 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.2.tar.gz
Algorithm Hash digest
SHA256 994a7db242864884f5fa52fc0a2b2fcda90ae4538a77a849f8e55493cdf7e388
MD5 a00263760e6d0922d29d353f579b035d
BLAKE2b-256 65773dd5efd34a19f0eb040b956b2329066bc33b67ec876f714020bdf5c9e1cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lothc-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4eb8f9fd03e0970a4e592117b661e6683e903bb62ffcc9b3fc3246ae859745
MD5 f55d7a0540f112631dcafc62175a8948
BLAKE2b-256 e3cdfaf7814ba1de50e81a3761bb8ba5f2f35713f155285615d372bb247ab00a

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

This release

0.0.2 This release

2 files

0.0.1

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