Python SDK
The Spartera Python SDK provides comprehensive access to all Spartera API
endpoints from Python applications.
Installation
Install the SDK using pip:
pip install spartera-api-sdk
Requirements
- Python 3.8 or higher
- pip package manager
Features
The Python SDK offers the following capabilities:
- Complete access to all Spartera API endpoints
- Automated data platform discovery and connection setup
- Legal compliance tools integration
- Programmatic marketplace asset publishing
- Environment variable support for credential management
- Analytics utilities and batch operations
- Asset management tools
Authentication
Configure authentication using environment variables:
import os
from spartera_api_sdk import SparteraClient
## Using environment variables
client = SparteraClient()
## Or direct configuration
client = SparteraClient(api_key="your-api-key")
Quick Start
from spartera_api_sdk import SparteraClient
## Initialize client
client = SparteraClient(api_key="your-api-key")
## Connect data warehouse
connection = client.connections.create({
"name": "My BigQuery Connection",
"type": "bigquery",
"credentials": {
"project_id": "your-project"
}
})
## Create and publish asset
asset = client.assets.create({
"name": "Sales Analytics",
"type": "sql",
"query": "SELECT * FROM sales_data",
"connection_id": connection.id
})
## Set pricing
client.assets.set_pricing(asset.id, {
"strategy": "per_query",
"price": 0.50
})
Error Handling
try:
asset = client.assets.get(asset_id)
except SparteraAPIError as e:
print(f"Error: {e.status_code} - {e.message}")
Advanced Features
The SDK supports bulk operations, performance analytics, and automated
recommendations for optimizing your data assets.
