Atlan Python Client
The `pyatlan` library is the official Python SDK for interacting with Atlan, a data governance and metadata management platform. It provides typed wrappers around the Atlan REST API, enabling users to programmatically search, discover, govern, and manage various data assets like tables, dashboards, and glossary terms. The current version, 9.4.0, includes experimental features for the next-generation `pyatlan_v9` and ongoing quality-of-life improvements. The library maintains an active release cadence with frequent updates.
Warnings
- breaking Major architectural shift in version 9.0.0, where the core data layer models transitioned from Pydantic v1 to `msgspec` for improved performance. This is part of the experimental `pyatlan_v9` initiative.
- gotcha In versions 9.2.0 through 9.3.1, the policy duplicate detection logic could inadvertently block legitimate policy *updates*, treating them as duplicate creations.
- gotcha In versions prior to 9.3.0, the `DQCondition.value` field's `Union` type ordering could incorrectly coerce integer values to strings during deserialization, leading to data type mismatches.
- gotcha Directly embedding API keys or other sensitive credentials in code is a security risk. API keys should never appear in logs or exception tracebacks.
Install
-
pip install pyatlan
Imports
- AtlanClient
from pyatlan.client import AtlanClient
- AsyncAtlanClient
from pyatlan.client.aio import AsyncAtlanClient
- FluentSearch
from pyatlan.model.fluent_search import FluentSearch
- Table
from pyatlan.model.assets import Table
Quickstart
import os
from pyatlan.client import AtlanClient
from pyatlan.model.fluent_search import FluentSearch
from pyatlan.model.assets import Table
# Configure with environment variables (recommended) or direct parameters
ATLAN_BASE_URL = os.environ.get('ATLAN_BASE_URL', 'https://<your-tenant>.atlan.com')
ATLAN_API_KEY = os.environ.get('ATLAN_API_KEY', 'YOUR_API_KEY') # Assign persona(s) to API token for access
if not ATLAN_API_KEY or 'YOUR_API_KEY' in ATLAN_API_KEY:
raise ValueError("Please set ATLAN_API_KEY environment variable or replace 'YOUR_API_KEY' with your actual key.")
if not ATLAN_BASE_URL or '<your-tenant>' in ATLAN_BASE_URL:
raise ValueError("Please set ATLAN_BASE_URL environment variable or replace '<your-tenant>.atlan.com' with your actual Atlan URL.")
try:
client = AtlanClient(base_url=ATLAN_BASE_URL, api_key=ATLAN_API_KEY)
# Example: Search for active Table assets
search_request = (
FluentSearch()
.where(FluentSearch.asset_type(Table))
.where(FluentSearch.active_assets())
.page_size(10)
.to_request()
)
response = client.asset.search(search_request)
print(f"Found {len(response.assets)} active Tables:")
for asset in response.assets:
print(f" - {asset.name} ({asset.qualified_name})")
except Exception as e:
print(f"An error occurred: {e}")