Skip to Content
Dashboard
SDKsAPI clientTypeScript SDK

TypeScript SDK

@notus-api/sdk: one typed method for every Notus API endpoint, for Node.js, Bun, Deno and edge runtimes.

Open in ChatGPT

@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/sdk

Use

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.

GroupCovers
walletsRegister user accounts, portfolio, portfolio history, transaction history, tax export
transfersTransfers
swapsConvert currencies, move money between networks (including external networks), limit orders, and US stocks and funds
userOperationsSubmit, track, batch, custom operations, cancel limit orders
bitcoinSubmit an approved Bitcoin transaction
liquidityPoolsCurrency pools (earn a share of exchange fees), positions and pool operations
fundsManaged investment fund catalog, holdings, deposits and redemptions
lendingDeposit to earn interest, borrow against a deposit, repay and withdraw
fiatPix quotes, deposits and withdrawals
kycIdentity verification sessions and identities
blockchainNetworks and assets
GroupCovers
walletsRegister wallets, portfolio, portfolio history, transaction history, tax export
transfersTransfers
swapsSwaps, cross-chain swaps, limit orders, tokenized stocks, Bitcoin, Stellar and Solana
userOperationsExecute, track, batch, custom operations, cancel limit orders
bitcoinBroadcast a signed Bitcoin transaction
liquidityPoolsPools, positions and every liquidity operation
fundsFund catalog, positions, deposits and redeems
lendingAave supply, borrow, repay and withdraw
fiatPix quotes, deposits and withdrawals
kycVerification sessions and identities
blockchainChains 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.

On this page