NodeJS

Cấu hình

Tham chiếu đầy đủ tham số Config cho Node.js SDK

Config

Config là đối tượng cấu hình trung tâm của SDK. Tạo instance với thông tin xác thực:

import { Config } from '@ssi.developer/ssi-sdk';

const config = new Config({
  clientId: 'YOUR_CLIENT_ID',
  apiKey: 'YOUR_API_KEY',
  apiSecret: 'YOUR_API_SECRET',
  privateKey: 'YOUR_PRIVATE_KEY',
});

Tất cả tham số cấu hình

Tham sốKiểuMặc địnhMô tả
clientIdstring""Client ID cho portfolio operations
apiKeystring""API key từ SSI
apiSecretstring""API secret từ SSI
privateKeystring""Private key RSA để ký lệnh giao dịch (XML format, base64-encoded)
apiUrlstring"https://api.ssi.com.vn"URL REST API
streamingUrlstring"wss://stream.ssi.com.vn/ws/v3"URL WebSocket streaming
timeoutnumber60000Timeout request (ms)
maxRetriesnumber5Số lần retry tối đa
retryDelaynumber2000Delay cơ sở giữa các lần retry (exponential backoff, ms)
rateLimitPerSecondnumber10Giới hạn request/giây (0 = không giới hạn)
proxystringundefinedProxy URL (HTTP hoặc SOCKS5)
logLevelstring"INFO"Mức log: DEBUG, INFO, WARNING, ERROR, CRITICAL

Cấu hình nâng cao

Debug logging

const config = new Config({
  clientId: 'YOUR_CLIENT_ID',
  apiKey: 'YOUR_API_KEY',
  apiSecret: 'YOUR_API_SECRET',
  logLevel: 'DEBUG',
});

Tuỳ chỉnh retry & rate limit

const config = new Config({
  clientId: 'YOUR_CLIENT_ID',
  apiKey: 'YOUR_API_KEY',
  apiSecret: 'YOUR_API_SECRET',
  maxRetries: 3,
  retryDelay: 1000,
  rateLimitPerSecond: 5,
});

Proxy

const config = new Config({
  clientId: 'YOUR_CLIENT_ID',
  apiKey: 'YOUR_API_KEY',
  apiSecret: 'YOUR_API_SECRET',
  proxy: 'http://proxy.example.com:8080',
});

Khuyến nghị

  • Lưu credentials (apiKey, apiSecret, privateKey) trong biến môi trường hoặc secret manager.
  • Thiếu apiKey/apiSecret sẽ gây lỗi xác thực.
  • Thiếu privateKey sẽ ảnh hưởng đến thao tác ký lệnh.
  • Đặt rateLimitPerSecond theo chính sách nền tảng.
  • Chỉ bật logLevel: 'DEBUG' trong môi trường phát triển.
  • Điều chỉnh timeout, maxRetries, và retryDelay theo workload thực tế.

Trên trang này