Python SDK
The OpenMetadata Python SDK provides a comprehensive interface for interacting with the OpenMetadata API. It offers type-safe operations for managing metadata entities and seamless integration with your Python applications.Installation
Install the OpenMetadata Python SDK using pip:Quick Start
Basic Connection
Working with Entities
Core Functionality
Entity Management
The Python SDK provides full CRUD operations for all OpenMetadata entities:Create or Update Entities
Retrieve Entities
List All Entities
Entity References
Advanced Features
Custom Configuration
Error Handling
Working with Versions
Common Use Cases
Data Discovery
Metadata Automation
Lineage Management
API Reference
The Python SDK provides a comprehensive API based on the OpenMetadata data model:Core Classes
OpenMetadata: Main client class for API interactionsOpenMetadataConnection: Connection configuration- Entity Classes: Type-safe representations of all OpenMetadata entities
Key Methods
create_or_update(data): Create or update an entityget_by_name(entity, fqn): Retrieve entity by fully qualified nameget_by_id(entity, entity_id): Retrieve entity by IDlist_entities(entity, **kwargs): List entities with paginationlist_all_entities(entity, **kwargs): Generator for all entitiesdelete(entity, entity_id): Delete an entityhealth_check(): Check API connectivity
Type Safety
The Python SDK is built on generated Pydantic models, providing:- Type hints for better IDE support
- Runtime validation of data structures
- Auto-completion for entity properties
- Error prevention through static typing
Best Practices
- Connection Management: Reuse OpenMetadata client instances
- Error Handling: Always handle potential exceptions
- Pagination: Use
list_all_entities()for large datasets - Performance: Specify only required fields when fetching entities
- Resource Cleanup: Call
metadata.close()when done