Quickstart
This walkthrough uses the TypeScript SDK against devnet. Prerequisites: Node 20 or newer and a funded Solana devnet keypair.
1. Install
npm install @n1xyz/nord-ts @solana/web3.js
2. Read market data
No account, session, or key is needed to read state.
import { Connection } from "@solana/web3.js";
import { Nord } from "@n1xyz/nord-ts";
const nord = await Nord.new({
webServerUrl: "https://api-devnet.n1.xyz",
app: process.env.APP_ADDRESS!,
solanaConnection: new Connection("https://api.devnet.solana.com"),
});
console.log(nord.markets.map((m) => [m.marketId, m.symbol]));
const orderbook = await nord.getOrderbook({ marketId: 0 });
console.log(orderbook.bids[0], orderbook.asks[0]);
Nord.new fetches /info, so nord.markets and nord.tokens carry the market
and token configuration of the deployment, including the decimals the SDK uses
to scale prices and sizes.
3. Create a user and open a session
Order entry is authorized by a session key, not by your wallet key on every action. See Accounts and sessions.
import { NordUser } from "@n1xyz/nord-ts";
const user = NordUser.fromPrivateKey(nord, process.env.PRIVATE_KEY!);
await user.updateAccountId(); // resolve the accounts owned by this wallet
await user.fetchInfo(); // load balances, positions, and open orders
await user.refreshSession(); // register the session key
updateAccountId throws if the wallet is not known to the exchange yet. Fund it
with a deposit, then re-run it once the deposit has been processed:
await user.depositSpl(100, 0); // 100 USDC (tokenId 0)
await user.updateAccountId();
4. Place and cancel an order
import { FillMode, Side } from "@n1xyz/nord-ts";
const { orderId, fills } = await user.placeOrder({
marketId: 0,
side: Side.Bid,
fillMode: FillMode.Limit,
isReduceOnly: false,
size: 0.001,
price: 50000,
});
console.log({ orderId, fills });
if (orderId !== undefined) {
await user.cancelOrder(orderId);
}
orderId is only present when part of the order rests on the book — a fully
filled immediate order returns fills and no orderId.
5. Follow your account
const accountSub = nord.subscribeAccount(user.accountIds![0]);
accountSub.on("message", (update) => console.log(update));
accountSub.on("error", (error) => console.error(error));
Next steps
- Trading — order types, reduce-only, client order IDs, self-trade prevention.
- Market data — orderbooks, trades, stats, historical queries.
- WebSockets — combined subscriptions and reconnect behavior.
- Direct API integration — if you are not using TypeScript.