コンテンツにスキップ
取引する

TypeScript SDK

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