# TypeScript SDK URL: /docs/sdks/typescript @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 [#install] ```package-install @notus-api/sdk ``` ## Use [#use] ```ts 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](/docs/api-reference): `notus..(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 [#errors] Any response outside 2xx throws `NotusAPIError`: ```ts 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 [#options] ```ts 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: ```ts await notus.swaps.createSwapOperation(input, { signal: AbortSignal.timeout(10_000) }) ``` `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`: ```ts 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 `Input` / `Result` pair per method, for example `CreateSwapOperationInput`. ## Versions [#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](/docs/guides/requests#api-versions).