Skip to content
Trade

TypeScript SDK

The same SDK that powers the web UI is exported under src/sdk/nexus and is the canonical client. It handles session lifecycle, signature derivation, automatic re-authentication on session expiry, and asset-id resolution.

import {
SessionClient,
PrivateKeyHashSigner,
InfoClient,
} from './sdk/nexus';
const baseUrl = 'https://api.bitnxs.com';
// 1. Build a signer from your API key (from "More → API Keys" page)
const signer = new PrivateKeyHashSigner('0x...');
// 2. Bind the session to your MAIN wallet (different from the API key address)
const session = new SessionClient({
signer,
userAddress: '0xABC...',
baseUrl,
});
// 3. Trade — session is opened lazily on first call
await session.order({
asset: 'BTC',
isBuy: true,
limitPx: '65000',
sz: '0.01',
reduceOnly: false,
orderType: { type: 'limit', tif: 'Gtc' },
});
// 4. Public reads via InfoClient
const info = new InfoClient({ baseUrl });
const fills = await info.userFills('0xABC...');