Preparation
Environment Requirements
- Operating System:
- Windows
- MacOS
- Linux
- Programming Language: C++14 or above
- Compiler: Any compiler supporting C++14 (e.g., GCC 5+, Clang 3.4+, MSVC 2015+)
Dependencies
The C++ SDK depends on the following third-party libraries:
| Library | Version | Purpose |
|---|---|---|
| cpprestsdk (C++ REST SDK) | latest | HTTP requests and JSON processing |
| OpenSSL | 3.x | Encryption and signing |
| Boost | >= 1.86 | Base library support |
| Protobuf | 5.28.3 | Serialization and deserialization of push data |
Get and Build the SDK
The SDK source code is hosted on GitHub: tigerfintech/openapi-cpp-sdk
git clone https://github.com/tigerfintech/openapi-cpp-sdk.git# Install dependencies (Homebrew)
brew install cmake openssl boost cpprestsdk protobuf
# One-click build (handles dependency versions automatically)
cd openapi-cpp-sdk
chmod +x scripts/build_linux_mac.sh
./scripts/build_linux_mac.shBuild output is located at output/Mac/Debug/ and output/Mac/Release/.
# Install base build tools
sudo apt-get install cmake git wget gcc g++ build-essential libssl-dev
# One-click build (automatically downloads and builds Boost 1.86 and Protobuf 5.28.3)
cd openapi-cpp-sdk
chmod +x scripts/build_linux_mac.sh
./scripts/build_linux_mac.shBuild output is located at output/Linux/Debug/ and output/Linux/Release/.
Install dependencies using vcpkg:
vcpkg install cpprestsdk boost openssl protobufThen use CMake to generate Visual Studio project files and build:
cd openapi-cpp-sdk
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=[vcpkg root]/scripts/buildsystems/vcpkg.cmake
cmake --build . --config ReleaseDevelopment Tools
Tiger OpenAPI works with popular AI coding tools (Cursor, Windsurf, Trae, VS Code + GitHub Copilot, Claude Code, Kiro, etc.) and traditional IDEs (IntelliJ IDEA, PyCharm, VS Code). Place the configuration file in your project directory and AI tools can automatically read the documentation to generate SDK code. See AI Skill and MCP Server for setup.
Register Developer Information
Before using the API, register as a developer and activate OpenAPI access.
Chrome browser is recommended.
Note: To activate Open API, you need to have a Tiger Brokers account with deposited funds. Developers and users will be required to sign an API authorization agreement.
Complete and submit the developer registration form on that page.
After successful registration, you can obtain the following information on this page:
- tiger_id: A unique ID assigned by the Open Platform to each developer, used to identify a developer. All API calls require tiger_id.
- account: The account ID required by trading APIs. There are three types:
- Global Account: Starts with uppercase letter U, e.g., U12300123
- Standard Account: A shorter numeric string (5-10 digits), e.g., 51230321
- Paper Account: 17-digit number, e.g., 20191106192858300
Note: You must save the private key locally and keep it secure to prevent leakage. If a leak is discovered, please update it immediately. The private key is not stored on Tiger's servers; you need to save it before refreshing the page.
The C++ SDK uses PKCS#8 format private keys. If you encounter issues using the SDK, first check whether the private key format is correct.
The generated tiger_openapi_config.properties file has the following format. The account value selects the default live or paper trading account. Institutional accounts must also configure the secret_key obtained from the institution center.
private_key_pk8=MIICeAIBADANBgkqhkiG9w0BAQ...
tiger_id=YOUR_TIGER_ID
account=12345678
license=TBHK
env=PRODThe license value is the licensing entity your account belongs to, one of TBNZ / TBSG / TBHK / TBAU / TBUS. Use the value from your downloaded configuration file; the examples below use TBHK.
Purchase Market Data (Optional)
Delayed market data is free. Real-time data requires a separate subscription for OpenAPI; subscriptions purchased for the mobile or desktop application do not provide OpenAPI market data access.
API Configuration
Configure the API before making requests.
Method 1: Using Configuration File (Recommended)
Export the configuration file tiger_openapi_config.properties from the developer website and place it in an appropriate system path. Then pass the path to the ClientConfig constructor:
#include "tigerapi/client_config.h"
using namespace TIGER_API;
// Initialize via configuration file (recommended)
ClientConfig config(false, U("your_config_directory_path"));Method 2: Direct Configuration in Code
#include "tigerapi/client_config.h"
using namespace TIGER_API;
ClientConfig config(U("your_tiger_id"), U("your_private_key"), U("your_account"));
config.license = U("TBHK");
config.lang = U("zh_CN");Common ClientConfig Properties
ClientConfig Properties// Constructor
ClientConfig config(false, U("your_config_directory_path"));
// Main properties
config.tiger_id; // Tiger ID
config.private_key; // Private key
config.account; // Account ID
config.license; // License; one of TBNZ / TBSG / TBHK / TBAU / TBUS, matching your account
config.lang; // Language, e.g., "zh_CN", "en_US"
config.secret_key; // Institutional account secret key
// Push-related configuration
config.use_full_tick; // Use full tick data; default false
config.send_interval; // Send interval (ms), default 10000
config.receive_interval; // Receive interval (ms), default 10000Updated 8 days ago
