A Python client library for interacting with Tapdata API
Project description
Tapdata Python SDK
A Python client library for interacting with Tapdata API.
Features
- 🔐 Complete authentication support
- 📦 Type-safe data models
- 🎯 Clean API interface
- 🔄 Connection and task management
- 📊 Task log queries
- ⚠️ Detailed error handling
- 📝 Comprehensive documentation and type hints
Installation
pip install tapdata-sdk
Or install from source:
git clone https://github.com/lddlww/tapdata_sdk.git
cd tapdata_sdk
pip install -e .
Quick Start
Basic Usage
from tapdata_sdk import TapdataClient
# Initialize client
client = TapdataClient("http://localhost:3030")
# Login
client.login("admin@test.com", "password")
# Query connections
connections = client.connections.list()
for conn in connections:
print(f"{conn.name}: {conn.status}")
# Query tasks
tasks = client.tasks.list()
for task in tasks:
print(f"{task.name}: {task.status}")
# Get Table Relation
table_relation = client.tasks.get_table_relation(task_id='xxx')
print(f"{table_relation.table_name_relation}")
Connection Management
from tapdata_sdk import ConnectionType, DatabaseType, Status
# Query source connections
source_connections = client.connections.list_source()
# Query MySQL connections
mysql_connections = client.connections.list_mysql()
# Query valid connections
valid_connections = client.connections.list_valid()
# Filter using enum types
connections = client.connections.list(
connection_type=ConnectionType.SOURCE,
database_type=DatabaseType.MYSQL,
status=Status.COMPLETE
)
# Get single connection details
connection = client.connections.get("connection_id")
print(connection.endpoint)
Task Management
# Query running tasks
running_tasks = client.tasks.list_running()
# Query tasks with specific status
tasks = client.tasks.list(status=Status.RUNNING)
# Get task details
task = client.tasks.get("task_id")
# Start task
client.tasks.start("task_id")
# Stop task
client.tasks.stop("task_id")
# Reset task
client.tasks.reset("task_id")
# Delete task
client.tasks.delete("task_id")
Query Task Logs
import time
# Get logs from the last hour
end_time = int(time.time() * 1000)
start_time = end_time - 3600000 # One hour ago
logs = client.tasks.get_logs(
task_id="task_id",
task_record_id="record_id",
start=start_time,
end=end_time,
page=1,
page_size=20
)
Error Handling
from tapdata_sdk import (
TapdataError,
TapdataAuthError,
TapdataTimeoutError,
TapdataConnectionError
)
try:
client.login("admin@test.com", "wrong_password")
except TapdataAuthError as e:
print(f"Authentication failed: {e.message}")
except TapdataTimeoutError as e:
print(f"Request timeout: {e.message}")
except TapdataConnectionError as e:
print(f"Connection error: {e.message}")
except TapdataError as e:
print(f"API error: {e.message}")
Advanced Configuration
# Custom timeout and SSL verification
client = TapdataClient(
base_url="https://api.tapdata.io",
timeout=60, # 60 second timeout
verify_ssl=False # Disable SSL verification (not recommended in production)
)
# Use existing access_token
client = TapdataClient(
base_url="http://localhost:3030",
access_token="your-existing-token"
)
# Check authentication status
if client.is_authenticated():
print("Authenticated")
# Logout
client.logout()
API Reference
TapdataClient
Main client class providing authentication and sub-client access.
Parameters:
base_url(str): API base URLaccess_token(str, optional): Access tokentimeout(int): Request timeout in seconds, default 30verify_ssl(bool): Whether to verify SSL certificate, default True
Methods:
login(email, password, secret): User loginlogout(): Logoutis_authenticated(): Check if authenticatedget_timestamp(): Get server timestamp
Properties:
connections: ConnectionClient instancetasks: TaskClient instance
ConnectionClient
Connection management client.
Methods:
list(connection_type, database_type, status, skip, limit): Query connection listget(connection_id): Get single connectionlist_source(): Get all source connectionslist_target(): Get all target connectionslist_mysql(): Get all MySQL connectionslist_clickhouse(): Get all ClickHouse connectionslist_mongodb(): Get all MongoDB connectionslist_valid(): Get all valid connectionslist_invalid(): Get all invalid connections
TaskClient
Task management client.
Methods:
list(status, skip, limit): Query task listget(task_id): Get single tasklist_running(): Get all running tasksstart(task_id): Start taskstop(task_id): Stop taskreset(task_id): Reset taskdelete(task_id): Delete taskget_logs(task_id, task_record_id, start, end, page, page_size, levels): Get task logs
Enum Types
from tapdata_sdk import ConnectionType, DatabaseType, Status, LogLevel
# Connection types
ConnectionType.SOURCE
ConnectionType.TARGET
# Database types
DatabaseType.MYSQL
DatabaseType.CLICKHOUSE
DatabaseType.MONGODB
DatabaseType.POSTGRESQL
DatabaseType.ORACLE
DatabaseType.SQLSERVER
# Status
Status.RUNNING
Status.COMPLETE
Status.ERROR
# ... more statuses
# Log levels
LogLevel.INFO
LogLevel.WARN
LogLevel.ERROR
LogLevel.DEBUG
Development
Setup Development Environment
# Clone repository
git clone <repository-url>
cd tapdata-sdk
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install dependencies
pip install -e ".[dev]"
Run Tests
pytest tests/
Code Formatting
black tapdata_sdk/
isort tapdata_sdk/
Changelog
v0.3.0 (2026-02-03)
- ✨ added TaskDetail and TaskRelation function
v0.2.0 (2026-01-29)
- ✨ Refactored code architecture with modular design
- 📦 Added data model classes (Connection, Task, TaskLog)
- 🎯 Improved enum types using Python Enum
- 🔧 Optimized error handling with multiple exception types
- 📝 Enhanced documentation and type hints
- 🏗️ Separated client responsibilities (ConnectionClient, TaskClient)
- 🔐 Improved authentication flow
- 📊 Optimized logging
v0.1.0
- 🎉 Initial release
License
MIT License
Contributing
Issues and Pull Requests are welcome!
Support
For questions, please submit an Issue or contact the maintainers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tapdata_sdk-0.3.0.tar.gz.
File metadata
- Download URL: tapdata_sdk-0.3.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d8a2338733d97c3d65851a7f332477a15cbf5fda184b58015b799ff8d0f84a3
|
|
| MD5 |
f3565779fe5aef75a6fb550904929200
|
|
| BLAKE2b-256 |
55851a7aa77c1a47a316cd42fffac6f342eb2fe02274e735c3c0551b23ca5e6a
|
File details
Details for the file tapdata_sdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tapdata_sdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89c0fe7cf423a07dbc1fd64b87fae30d9207c92c2827a06815a70c370fb35140
|
|
| MD5 |
2c4ccd3c2325d99c4323e43bae9c3c04
|
|
| BLAKE2b-256 |
47efb63a15cfbb7669c23aac1febe76e8e5a0242ec700000e579eedf9c800183
|