Skip to main content

Runtime library for ReflectAPI Python clients

Project description

reflectapi-runtime

Runtime support library for Python clients generated by reflectapi. Generated code imports from reflectapi_runtime; you don't normally call this library directly.

What it provides

  • ClientBase / AsyncClientBase — base classes used by the generated Client / AsyncClient. They wrap httpx and handle request build-up, Pydantic-based response validation, and middleware.
  • ApiResponse[T, E] — typed wrapper around the response value, transport metadata, and the optional typed error.
  • ApplicationError, NetworkError, TimeoutError, ValidationError — exceptions raised by the generated methods on non-2xx, transport, and validation failures respectively.
  • ReflectapiOption — three-state Option used by the generated models (some / none / undefined) so absent and explicit-null can round-trip.
  • Authentication helpers (BearerTokenAuth, APIKeyAuth, BasicAuth, OAuth2ClientCredentialsAuth, OAuth2AuthorizationCodeAuth).
  • Middleware, batching, and testing utilities (MockClient, CassetteMiddleware).

Streaming endpoints

Endpoints declared with Builder::stream_route on the server are exposed on the generated client as ordinary methods that return an iterator:

async with AsyncClient("http://localhost:3000") as client:
    async for event in client.pets.cdc_events(headers=headers):
        ...  # process each event

The sync client returns a regular Iterator; both validate each event against the declared item model. The wire format is Server-Sent Events (data: <json>\n\n); init failures (4xx/5xx) raise ApplicationError and do not enter the iterator. Breaking out of the loop or calling stream.aclose() releases the underlying HTTP connection.

Validation is strict: an event whose payload doesn't match the item model (for example, an unknown discriminated-union variant added by a newer server) raises ValidationError mid-stream and the iterator terminates. Items received before the bad event are still delivered.

Compatibility

Python 3.12+. The package targets the same reflectapi minor version as the schema you generate from; mismatches will surface at import time.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reflectapi_runtime-0.17.2a3.tar.gz (64.9 kB view details)

Uploaded Source

Built Distribution

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

reflectapi_runtime-0.17.2a3-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file reflectapi_runtime-0.17.2a3.tar.gz.

File metadata

  • Download URL: reflectapi_runtime-0.17.2a3.tar.gz
  • Upload date:
  • Size: 64.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for reflectapi_runtime-0.17.2a3.tar.gz
Algorithm Hash digest
SHA256 e6cfa36734dde4dd1a5cf2fb55c32bc7e69a44489573a86e27f26840bb6334a8
MD5 438dbc702e2fa18ec168e3cb07690e21
BLAKE2b-256 29ade49d31b4b1ca1bce5c4ca04a90d4d57f9d36fa9fa86381fb7c51780bf4b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for reflectapi_runtime-0.17.2a3.tar.gz:

Publisher: release.yml on thepartly/reflectapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file reflectapi_runtime-0.17.2a3-py3-none-any.whl.

File metadata

File hashes

Hashes for reflectapi_runtime-0.17.2a3-py3-none-any.whl
Algorithm Hash digest
SHA256 6197f03ba0d94e2f763230c4fb9e2baa571bd2600838da022f83db7c5b1042ff
MD5 73756063dfa9cd8c71625e8b6d0b26a0
BLAKE2b-256 2abc63e5231b87a7b947abf81c0b37a0d71f094c875dc579c3e5b9d8df6e07f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for reflectapi_runtime-0.17.2a3-py3-none-any.whl:

Publisher: release.yml on thepartly/reflectapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page