Using types
Nested request parameters are TypedDicts. Responses are Pydantic models which also provide helper methods for things like:- Serializing back into JSON,
model.to_json() - Converting to a dictionary,
model.to_dict()
python.analysis.typeCheckingMode to basic.
Nested params
Nested parameters are dictionaries, typed usingTypedDict. Bracketed query parameters in the REST API map to a single keyword argument that takes a dictionary, so filter[country_code]=US becomes filter={"country_code": "US"}. The exception is pagination: on list methods paginated with page[...], page[number] and page[size] are flattened to the page_number and page_size keyword arguments (there is no page= or limit= argument on those methods).
File uploads
Request parameters that correspond to file uploads can be passed asbytes, or a PathLike instance or a tuple of (filename, contents, media type).
PathLike instance, the file contents will be read asynchronously automatically.
Pagination
List methods in the Telnyx API are paginated. This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:.has_next_page(), .next_page_info(), or .get_next_page() methods for more granular control working with pages: