Skip to main content

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.
This page documents the original client (metadata.ingestion.ometa.ometa_api.OpenMetadata). For new code, use SDK 2.0 (metadata.sdk) where it supports the operation. For more information, see Which Python SDK Should I Use?.

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 configuration
  • raw_data (bool, optional): Whether to return raw data. Defaults to False.

Core Methods

Entity Retrieval
Parameters:
  • entity: Entity type class (e.g., Table, Database)
  • fqn / entity_id: Entity identifier
  • fields: Optional list of additional fields to include
  • nullable: Whether to return None if entity not found
Returns: Entity instance or None
Entity Creation and Updates
Parameters:
  • data: Create entity request object
Returns: Created or updated entity
Entity Listing
Parameters:
  • entity: Entity type to list
  • fields: Extra fields to return
  • after: Pagination cursor
  • limit: Number of entities per page/batch
  • params: Additional query parameters
  • skip_on_failure: Whether to continue on individual failures
Returns: EntityList for list_entities, Iterable for list_all_entities
Entity Deletion
Parameters:
  • entity: Entity type
  • entity_id: Entity ID to delete
  • recursive: Whether to delete recursively
  • hard_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:
This dictionary maps entity classes to their corresponding API endpoint suffixes.

Best Practices

  1. Reuse Client Instances: Create one Collate client and reuse it
  2. Handle Exceptions: Always wrap API calls in try-catch blocks
  3. Use Generators: Use list_all_entities() for large datasets to avoid memory issues
  4. Specify Fields: Only request fields you need to improve performance
  5. Close Connections: Always call close() when finished
  6. Type Safety: Use type hints and let your IDE help with auto-completion

Performance Considerations

  • Use list_all_entities() instead of list_entities() with large limits
  • Specify only required fields in the fields parameter
  • Use appropriate limit values for pagination
  • Cache entity references when possible
  • Close connections to free resources