Request and response types#

Requests made to the Tonita API can often result in complex response objects; requests themselves can sometimes be rather complex. The Tonita Python library uses dataclasses to keep these objects organized and predictable.

Specifically, every function in the Tonita Python library will return a dataclass. For example, a call to tonita.listings.add() will return a tonita.datatypes.listings.AddListingsResponse, and a call to tonita.search() will return a tonita.datatypes.search.SearchResponse. While some of these dataclasses will be relatively simple with only a few fields, others can be more complex. Dataclasses make clear the schema of the returned object and how that object’s data can be accessed.

Unlike return values, the inputs to functions in the Tonita Python library are not always dataclasses. However, function inputs sometimes have the potential to become very complex (for example, tonita.eval.submit() can take as input multiple search requests). In such cases, we provide dataclasses for you to organize and package your inputs.

For full documentation of the structure of the dataclasses we use, see our guides or API reference.