TypeScript SDK
@notus-api/sdk: one typed method for every Notus API endpoint, for Node.js, Bun, Deno and edge runtimes.
@notus-api/sdk is the official TypeScript client. It is generated from the API's OpenAPI spec, so every public endpoint has a method with typed input and output, and a new endpoint appears in the next release on its own.
Use it on your server: it sends your API key, which must never reach a browser or a mobile app.
Install
npm install @notus-api/sdkUse
import { Notus, NotusAPIError } from '@notus-api/sdk'
const notus = new Notus({ apiKey: process.env.NOTUS_API_KEY })
const { chains } = await notus.blockchain.listChains()
const portfolio = await notus.wallets.getPortfolio({
walletAddress: '0x6e397ddf51d9f15dbe0414538e7529f51f2e5464',
})Methods are grouped like the API reference: notus.<group>.<operation>(input). The input is one flat object with the path, query and body fields, named exactly as the API names them.
| Group | Covers |
|---|---|
wallets | Register user accounts, portfolio, portfolio history, transaction history, tax export |
transfers | Transfers |
swaps | Convert currencies, move money between networks (including external networks), limit orders, and US stocks and funds |
userOperations | Submit, track, batch, custom operations, cancel limit orders |
bitcoin | Submit an approved Bitcoin transaction |
liquidityPools | Currency pools (earn a share of exchange fees), positions and pool operations |
funds | Managed investment fund catalog, holdings, deposits and redemptions |
lending | Deposit to earn interest, borrow against a deposit, repay and withdraw |
fiat | Pix quotes, deposits and withdrawals |
kyc | Identity verification sessions and identities |
blockchain | Networks and assets |
| Group | Covers |
|---|---|
wallets | Register wallets, portfolio, portfolio history, transaction history, tax export |
transfers | Transfers |
swaps | Swaps, cross-chain swaps, limit orders, tokenized stocks, Bitcoin, Stellar and Solana |
userOperations | Execute, track, batch, custom operations, cancel limit orders |
bitcoin | Broadcast a signed Bitcoin transaction |
liquidityPools | Pools, positions and every liquidity operation |
funds | Fund catalog, positions, deposits and redeems |
lending | Aave supply, borrow, repay and withdraw |
fiat | Pix quotes, deposits and withdrawals |
kyc | Verification sessions and identities |
blockchain | Chains and tokens |
Errors
Any response outside 2xx throws NotusAPIError:
try {
await notus.swaps.createSwapOperation(input)
} catch (error) {
if (!(error instanceof NotusAPIError)) throw error
console.log(error.status, error.id, error.message, error.extra, error.traceId)
}id is the stable error code (NOT_AUTHORIZED_TOKENS, EXECUTE_USER_OP…), the one to branch on. message is readable text, in Portuguese when you send Accept-Language: pt. Send traceId to Notus when you report a problem.
Options
const notus = new Notus({
apiKey: process.env.NOTUS_API_KEY,
baseUrl: 'https://api.notus.team',
timeoutMs: 30_000,
headers: () => ({ 'Accept-Language': 'pt' }),
})headers runs before every request. Each method also takes { headers, signal, timeoutMs } as a second argument, for example to cancel a slow quote:
await notus.swaps.createSwapOperation(input, { signal: AbortSignal.timeout(10_000) })Calling a route by hand
notus.rest is the HTTP client the methods use. get, post, put, patch and delete call any path, typed by the generic you pass, and throw the same NotusAPIError:
const { quotes } = await notus.rest.post<{ quotes: unknown[] }>('/api/v1/crypto/swap', {
body: input,
})The package also exports the raw types generated from the spec (components, operations, paths) and an <Operation>Input / <Operation>Result pair per method, for example CreateSwapOperationInput.
Versions
The SDK is released from the API's main branch. A removed or renamed method is a major version; any other change to the API is a minor version. It follows the API version of your project, like any other client: see API versions.