TypeScript SDK

Tiger Open API TypeScript SDK, providing market data queries, order placement, account management, and real-time push notifications.

v0.3.0 introduces a fully typed request/response API. Every QuoteClient / TradeClient method returns a domain object (e.g. Brief, Kline, Order, PlaceOrderResult) instead of a raw ApiResponse envelope. Request parameters are written in idiomatic camelCase in TypeScript and the client automatically converts them to snake_case on the wire. Array responses that the server wraps in { items: [...] } are unwrapped for you. See CHANGELOG.

Installation

npm install @tigeropenapi/tigeropen
# or the unscoped alias
npm install tigeropen
# or
yarn add @tigeropenapi/tigeropen
# or
pnpm add @tigeropenapi/tigeropen

Requires Node.js >= 16.0.0.

Configuration

The SDK supports multiple configuration methods. Priority: Environment Variables > Code Settings (including config file) > Auto-discovered config file > Defaults.

The SDK automatically searches for a config file at these locations (no explicit path needed):

  1. Current directory: ./tiger_openapi_config.properties
  2. Home directory: ~/.tigeropen/tiger_openapi_config.properties

Method 1: Load from properties file (recommended)

import { createClientConfig } from '@tigeropenapi/tigeropen';

// Specify a config file path
const config = createClientConfig({
  propertiesFilePath: '/path/to/tiger_openapi_config.properties',
});

// Or pass no arguments — SDK auto-discovers the config file
const config = createClientConfig();

Configuration file format:

tiger_id=your_developer_id
private_key=your_rsa_private_key
account=your_trading_account
license=TBUS

Method 2: Set directly in code

import { createClientConfig } from '@tigeropenapi/tigeropen';

const config = createClientConfig({
  tigerId: 'your_tiger_id',
  privateKey: 'your_rsa_private_key',
  account: 'your_trading_account',
});

Method 3: Environment variables

export TIGEROPEN_TIGER_ID=your_developer_id
export TIGEROPEN_PRIVATE_KEY=your_rsa_private_key
export TIGEROPEN_ACCOUNT=your_trading_account
export TIGEROPEN_TOKEN=your_token  # Required for TBHK license

Configuration Options

OptionDescriptionRequiredDefault
tigerIdDeveloper IDYes-
privateKeyRSA private key (PK1 and PK8 compatible)Yes-
accountTrading accountNo-
licenseLicense type (e.g. TBUS)No-
languageLanguage (zh_CN/en_US)Nozh_CN
timeoutRequest timeout (seconds)No15
tokenTBHK license tokenNo-

Auto-Detection

  • Device ID: Automatically detected from network interface MAC address (os.networkInterfaces())
  • Dynamic domains: SDK fetches the latest server addresses from the domain garden (enabled by default)
  • Quote server: SDK resolves a dedicated quote server URL (LICENSE-QUOTE domain key)
  • Signature verification: Built-in Tiger public key for HTTP response signature verification

Quote Client

The QuoteClient takes an HttpClient configured to talk to the quote server. Pass { useQuoteServerUrl: true } as the third HttpClient argument so that requests are routed to the quote endpoint:

import {
  createClientConfig,
  HttpClient,
  QuoteClient,
} from '@tigeropenapi/tigeropen';

const config = createClientConfig();
const quoteHttpClient = new HttpClient(config, undefined, { useQuoteServerUrl: true });
const quoteClient = new QuoteClient(quoteHttpClient);

Trade Client

The TradeClient takes a regular HttpClient and the trading account:

import {
  createClientConfig,
  HttpClient,
  TradeClient,
} from '@tigeropenapi/tigeropen';

const config = createClientConfig();
const tradeClient = new TradeClient(new HttpClient(config), config.account);

Push Client

The PushClient is constructed directly from the config and uses a Protobuf + TLS protocol:

import { createClientConfig, PushClient } from '@tigeropenapi/tigeropen';

const config = createClientConfig();
const pushClient = new PushClient(config);
await pushClient.connect();