Skip to content

SDK API Reference / TDX

Class: TDX

TDX SDK - Main class

Provides programmatic access to Treasure Data operations

Properties

api

readonly api: RawAPI

Raw API access - Make direct HTTP requests to any TD API endpoint


engage

readonly engage: EngageSDK

Engage operations API (campaigns, templates, workspaces)


jobs

readonly jobs: JobSDK

Job operations API


llm

readonly llm: LLMSDK

LLM operations API (agents, chat)


query

readonly query: QuerySDK

Query operations SDK

Provides Trino query execution and schema introspection:

  • execute() - Execute arbitrary SQL queries
  • listDatabases() - List databases
  • listTables() - List tables
  • describeTable() - Describe table schema
  • showTable() - Show table contents

segment

readonly segment: SegmentSDK

Segment operations API (CDP)


workflow

readonly workflow: WorkflowSDK

Workflow operations API

Accessors

logger

Get Signature

get logger(): TDXLogger

Logger instance

Returns

TDXLogger

Methods

create()

static create(config): TDX

Create TDX SDK instance from configuration

This is the recommended way to create a TDX instance.

Parameters

config

SDKConfig = {}

SDK configuration options

Returns

TDX

TDX instance

Example

typescript
import { TDX } from '@treasuredata/tdx/sdk';

// Method 1: Pass API key directly (works everywhere)
const tdx = TDX.create({
  site: 'us01',
  apiKey: 'your_key_id/your_key_secret'
});

// Method 2: Load from environment variable (Node.js only)
// export TD_API_KEY_US01=your_api_key
const tdx = TDX.create({ site: 'us01' });

// Method 3: Use defaults (us01, API key from env)
const tdx = TDX.create();

// Use the SDK
const databases = await tdx.query.listDatabases();