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,apiSecretfrom SSIprivateKeyfor signing trading orders- OTP for Trading/Stream authentication flow
Installation
npm install @ssi.developer/ssi-sdkThe 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- Create
Configwith credentials. - Initialize
Authwithnew Auth(config). - Call
await auth.authenticate(otp)— omitotpfor market data only. - Initialize the client you need (
Data,Trading,Stream) withauth. - For
Stream, callawait stream.streaming.connect()before subscribing. - 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'inConfigfor troubleshooting. - Store credentials (
apiKey,apiSecret,privateKey) in environment variables or a secret manager. - Call
stream.disconnect()to properly clean up resources.