Advanced
Logging
We use the standard librarylogging module.
You can enable logging by setting the environment variable TELNYX_LOG to info.
debug for more verbose logging.
How to tell whether None means null or missing
In an API response, a field may be explicitly null, or missing entirely; in either case, its value is None in this library. You can differentiate the two cases with .model_fields_set:
Accessing raw response data (e.g. headers)
The “raw” Response object can be accessed by prefixing.with_raw_response. to any HTTP method call, e.g.,
APIResponse object.
The async client returns an AsyncAPIResponse with the same structure, the only difference being awaitable methods for reading the response content.
.with_streaming_response
The above interface eagerly reads the full response body when you make the request, which may not always be what you want.
To stream the response body, use .with_streaming_response instead, which requires a context manager and only reads the response body once you call .read(), .text(), .json(), .iter_bytes(), .iter_text(), .iter_lines() or .parse(). In the async client, these are async methods.
Making custom/undocumented requests
This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.Undocumented endpoints
To make requests to undocumented endpoints, you can make requests usingclient.get, client.post, and other
http verbs. Options on the client will be respected (such as retries) when making this request.
Undocumented request params
If you want to explicitly send an extra param, you can do so with theextra_query, extra_body, and extra_headers request
options.
Undocumented response properties
To access undocumented response properties, you can access the extra fields likeresponse.unknown_prop. You
can also get all the extra fields on the Pydantic model as a dict with
response.model_extra.
Configuring the HTTP client
You can directly override the httpx client to customize it for your use case, including:- Support for proxies
- Custom transports
- Additional advanced functionality
with_options():
Managing HTTP resources
By default the library closes underlying HTTP connections whenever the client is garbage collected. You can manually close the client using the.close() method if desired, or with a context manager that closes when exiting.
Versioning
This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:- Changes that only affect static types, without breaking runtime behavior.
- Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
- Changes that we do not expect to impact the vast majority of users in practice.