Skip to main content

Typed Core

Shared core types and utilities for Typed Clients

PyPI version License

Every Typed Client builds its core on top of this package. Prefer it over a client-local copy of the same logic — a client's own core/ should hold only what's genuinely venue-specific (envelope extraction, error mapping, signing, wire quirks), not a reimplementation of transport, timestamps, or error types.

Installation

pip install typed-core

What it provides

module contents
typed_core.exceptions Error, NetworkError, ValidationError, ApiError (BadRequest, AuthError, RateLimited), LogicError
typed_core.http async HTTP client and response helpers
typed_core.ws websocket socket, streams, JSON-RPC, streams-over-RPC
typed_core.times TimeConverter, EpochConverter, IsoConverter — parse/dump between a venue's wire timestamp and a real datetime
typed_core.util RateLimit, paging and stream helpers
from typed_core.times import EpochConverter, IsoConverter

timestamp_millis = EpochConverter.milliseconds()  # epoch, milliseconds
timestamp_iso = IsoConverter()                    # RFC 3339, Z-suffixed

A wire value carrying no offset is read as UTC, matching what dump already assumes of a naive datetime; pass tz=None to keep it naive instead. Every converter raises ValueError on a value of the wrong kind, so a null on a non-nullable field arrives as an ordinary validation error rather than an AttributeError.

HTTP configuration

from typed_core.http import HttpClient

async with HttpClient(timeout=30, proxy="http://localhost:8080") as http:
  response = await http.request("GET", "https://example.com")
  response = await http.request("GET", "https://example.com", timeout=120)

timeout defaults to five seconds of network inactivity; None disables timeouts. Use httpx.Timeout for separate connect, read, write, and pool limits. Per-request timeout overrides the client default. Requests are single-attempt, with retries left to the caller.

proxy accepts a URL or an httpx.Proxy, including authenticated proxies. When omitted, HTTPX uses HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY from the environment. An explicit proxy overrides environment proxy routing, including NO_PROXY. For an HTTPS destination, an http:// proxy URL commonly works by tunneling the TLS connection. trust_env=False ignores HTTPX environment settings (proxies and certificate locations), but still uses an explicit proxy. See HTTPX environment variables.

limits continues to control connection pooling. The existing default disables keepalive when uppercase HTTP_PROXY or HTTPS_PROXY is present; pass explicit httpx.Limits to override it, including when using trust_env=False.

All construction settings apply when the underlying HTTPX client is lazily created. An existing client supplied through the legacy _client field keeps its own configuration. A Typed client accepting http=... manages that transport's cleanup when its context exits; use separate transports for independently managed client lifetimes.

Paging

Every generated <method>_paged returns a PaginatedResponse: awaitable (every row, flattened) and async-iterable (one page of rows at a time). Each page is one pure next(state) call, so a caller can retry or resume a single page rather than the whole walk.

from typed_core import PaginatedResponse

paging = client.market.kline_paged(symbol='BTCUSDT', interval='1', start=start, end=end)
candles = await paging                       # every row, flattened
async for rows in paging: ...                # one page at a time
async for page in paging.pages():            # Page(rows, state, next), for checkpointing
  checkpoint(page.next)
paging.resume(saved_state)                   # restart from a checkpointed state
paging.via(retried)                          # route every page fetch through a middleware

via(call) hands each page fetch to call as one zero-argument coroutine function, so a retry or logging layer wraps a page without unrolling the loop by hand.

Clients re-export the exceptions users are expected to catch from their own package root, so from kraken import AuthError works while implementation imports still come from typed_core. Route those re-exports through lazy_loader.attach_stub, not a plain from typed_core.exceptions import ... in an __init__.py — the latter breaks type-checking for every downstream consumer of a py.typed package.

License

MIT — see LICENSE.

Release files for typed-core 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typed-core 0.9.0
File Size Uploaded
typed_core-0.9.0.tar.gz 35.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typed-core 0.9.0
File Interpreter ABI Platform
typed_core-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.8 kB

Release files / typed_core-0.9.0.tar.gz

Download URL typed_core-0.9.0.tar.gz
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f5abdceb2f5ce4252dfb71eafbf4f83d5680f69d690795193a44f51fbc84d6
BLAKE2b-256 checksum
How to use checksums
08c6307a143b7b82f252770b800247b5a46c5f5bdea5bb7c66a7771a6a8ed255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / typed_core-0.9.0-py3-none-any.whl

Download URL typed_core-0.9.0-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50b998d008243cca939944f8b8ca6b13a4fb8a55dd9eeca31bf01ac9ab5bfaa1
BLAKE2b-256 checksum
How to use checksums
c2ea42cca020a87a9b86978209a01d82f4dae65d40436574e7b2c984827c1e50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.2

2 release files

0.9.1

2 release files

This release

0.9.0 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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