NodeJS

Installation & Setup

Installation and setup guide for Node.js SDK

Environment Requirements

  • Node.js >=18
  • Network access to REST API and WebSocket endpoints
  • clientId, apiKey, apiSecret from SSI
  • privateKey for signing trading orders
  • OTP for Trading/Stream authentication flow

Installation

npm install @ssi.developer/ssi-sdk

The SDK supports both CommonJS and ES Module (dual CJS/ESM).

Configuration

Create a Config object with your credentials:

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',
});

Initialization Flow

Config → Auth → authenticate(otp) → Data / Trading / Stream
  1. Create Config with credentials.
  2. Initialize Auth with new Auth(config).
  3. Call await auth.authenticate(otp) — omit otp for market data only.
  4. Initialize the client you need (Data, Trading, Stream) with auth.
  5. For Stream, call await stream.streaming.connect() before subscribing.
  6. Call stream.disconnect() to clean up resources.

Usage Examples

Market data only (no OTP required)

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

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

const auth = new Auth(config);
await auth.authenticate();

const data = new Data(auth);
const ohlc = await data.marketData.getOhlc1Minute('SSI');

Trading (OTP required)

import { Auth, Trading, Config, OrderSide } 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',
});

const auth = new Auth(config);
await auth.authenticate('YOUR_OTP');

const trading = new Trading(auth);
const accounts = await trading.account.getAccountInfo();

Realtime streaming (OTP required)

import { Auth, Stream, 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',
});

const auth = new Auth(config);
await auth.authenticate('YOUR_OTP');

const stream = new Stream(auth);

stream.streaming.onData = (msg) => {
  console.log(msg);
};

await stream.streaming.connect();
await stream.streaming.subscribeSymbolTrade(['SSI']);
await stream.streaming.wait();

Tips

  • Authenticate before calling any token-protected API.
  • For streaming, call connect() after successful authentication.
  • Use logLevel: 'DEBUG' in Config for troubleshooting.
  • Store credentials (apiKey, apiSecret, privateKey) in environment variables or a secret manager.
  • Call stream.disconnect() to properly clean up resources.

On this page