Python SDK API Reference
The Collate Python SDK provides a high-level interface for interacting with the Collate API. It is based on generated Pydantic models from JSON schemas and provides a typed approach to working with Collate entities.Core Classes
Collate
The main client class that provides a generic interface to the Collate API. It implements polymorphism across all different entities and includes specific functionalities inherited from mixins.Constructor
config(CollateConnection): Connection configurationraw_data(bool, optional): Whether to return raw data. Defaults toFalse.
Core Methods
Entity Retrieval
entity: Entity type class (e.g.,Table,Database)fqn/entity_id: Entity identifierfields: Optional list of additional fields to includenullable: Whether to returnNoneif entity not found
None
Entity Creation and Updates
data: Create entity request object
Entity Listing
entity: Entity type to listfields: Extra fields to returnafter: Pagination cursorlimit: Number of entities per page/batchparams: Additional query parametersskip_on_failure: Whether to continue on individual failures
EntityList for list_entities, Iterable for list_all_entities
Entity Deletion
entity: Entity typeentity_id: Entity ID to deleterecursive: Whether to delete recursivelyhard_delete: Whether to perform hard delete
Utility Methods
Type Helper Methods
Exception Classes
MissingEntityTypeException
Raised when receiving an Entity Type not covered in the suffix generation list.InvalidEntityException
Raised when receiving an entity not supported in an operation.EmptyPayloadException
Raised when receiving no data, even if no exception during the API call is received.Usage Examples
Basic Entity Operations
Working with Entity References
Pagination and Filtering
Error Handling
Connection Management
Global Variables
ROUTES
The SDK maintains a routing table for mapping entity types to API endpoints:Best Practices
- Reuse Client Instances: Create one
Collateclient and reuse it - Handle Exceptions: Always wrap API calls in try-catch blocks
- Use Generators: Use
list_all_entities()for large datasets to avoid memory issues - Specify Fields: Only request fields you need to improve performance
- Close Connections: Always call
close()when finished - Type Safety: Use type hints and let your IDE help with auto-completion
Performance Considerations
- Use
list_all_entities()instead oflist_entities()with large limits - Specify only required fields in the
fieldsparameter - Use appropriate
limitvalues for pagination - Cache entity references when possible
- Close connections to free resources