Skip to main content

Python SDK

The OpenMetadata Python SDK provides typed helpers for common OpenMetadata API operations. SDK operations live on plural facade classes such as Tables, Databases, and Users. The singular generated entity classes, such as metadata.generated.schema.entity.data.table.Table, are Pydantic models and do not expose SDK CRUD methods.

Installation

Install the OpenMetadata Python SDK using pip:

Quick Start

Basic Connection

You can also configure from environment variables (OPENMETADATA_HOST or OPENMETADATA_SERVER_URL, and OPENMETADATA_JWT_TOKEN or OPENMETADATA_API_KEY):

Working with Entities

Core Functionality

Entity Management

The Python SDK facade classes provide common CRUD operations for supported OpenMetadata entities:

Create or Update Entities

Retrieve Entities

List All Entities

List with Filters

Update Entities

Delete Entities

Entity References

Advanced Features

Error Handling

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

  • Entity facade classes (Tables, Databases, DatabaseSchemas, DatabaseServices, Users, etc.): plural static-method interfaces, no instantiation required
  • configure(): One-time global setup for host and JWT token
  • to_entity_reference(entity): Convert a retrieved entity to an EntityReference for use in relationships
  • Entity Request Classes: Pydantic-based typed request objects (e.g., CreateTableRequest)

Key Methods

Each entity class exposes the same consistent interface:
  • EntityClass.create(request): Create a new entity
  • EntityClass.retrieve(entity_id): Retrieve entity by UUID
  • EntityClass.retrieve_by_name(fqn, fields=[]): Retrieve entity by fully qualified name
  • EntityClass.list(limit=10, after=None, before=None, fields=None, filters=None): List one page of entities as an EntityList
  • EntityClass.list_all(batch_size=100, fields=None, filters=None): Fetch all pages
  • EntityClass.update(entity): Update an existing entity by reading entity.id
  • EntityClass.delete(entity_id, recursive=False, hard_delete=False): Delete an entity
The facade classes do not expose patch(entity_id, json_patch) helpers. For ordinary partial updates, retrieve the entity, mutate a copy, and call update(entity). For lower-level patch flows, use the OpenMetadata client returned by metadata.sdk.client().

Current Facade Coverage

The SDK currently exports facade classes for common data assets, services, governance, team/user, and data quality entities, including Tables, Databases, DatabaseSchemas, DatabaseServices, Dashboards, Pipelines, MLModels, Glossaries, GlossaryTerms, Classifications, Tags, Teams, Users, TestCases, TestDefinitions, and TestSuites. If a facade does not exist for an entity yet, use the underlying OpenMetadata client returned by metadata.sdk.client() or the ingestion client APIs directly.

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

  1. Configure once: Call configure() once at application startup and reuse globally; no need to pass a client object around
  2. Error Handling: Always handle APIError exceptions for robust integrations
  3. Pagination: Use list_all() for full auto-pagination or list() with after/before cursors for page-by-page control
  4. Performance: Specify only required fields when fetching entities (e.g., fields=["owners", "tags"])