콘텐츠로 이동
거래하기

TypeScript SDK

웹 UI를 구동하는 동일한 SDK가 src/sdk/nexus에 익스포트되어 있으며, 이것이 표준 클라이언트입니다. 세션 수명, 서명 파생, 만료 시 자동 재인증, 자산 ID 해석을 처리합니다.

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...');