Quick start
Quick start
The public npm package awaits its official release — see Installation. The examples below show the API surface; you can also try it live in Lab.
1. Create a client and read
import { createNutrimaticSdk } from '@nutrimatic/sdk'
const sdk = createNutrimaticSdk({
ledgers: [{ id: 'evm:421018', kind: 'evm', chainId: 421018, alias: 'infinite-mainnet' }],
mode: 'read',
integrationContext: 'client', // 'client' (browser, SPA, mobile) | 'backend' (server)
})
const pairs = await sdk.easy.read.listPairs()
const sub = sdk.live.watchPair({
pair: '42-USDT',
chart: { interval: '1h' },
onUpdate: (snap) => {
// snap.spot, snap.chart, snap.trades, snap.pool — keep your UI in sync
},
})
// later: sub.unsubscribe()
| Step | What you do |
|---|---|
| Package | Watch official channels for @nutrimatic/sdk — Installation |
| Init | Pass ledgers, mode, and integrationContext |
| Live reads | Call sdk.live.watchPair / watchInstrument (Live) |
| One-shot / history | easy.read, chart windows, feeds when you need paging |
Omit apiBaseUrl to use the canonical Telemetry host. Override only for a test host or your own Telemetry — Configuration.
2. First day — from chart to swap
When you are ready to trade (not only read), use mode: 'full', pass a wallet, then quote → swap → check status.
import { createNutrimaticSdk, type WalletAdapter } from '@nutrimatic/sdk'
const wallet: WalletAdapter = myWalletAdapter // see Wallet adapter
const sdk = createNutrimaticSdk({
ledgers: [{ id: 'evm:421018', kind: 'evm', chainId: 421018, alias: 'infinite-mainnet' }],
mode: 'full',
integrationContext: 'client',
wallet,
})
// Optional: show the connected wallet's balance (owner omitted → wallet address)
const balance = await sdk.balances.getBalance({
instrumentId: 'evm:421018:instrument:42',
})
const quote = await sdk.routing.quote({
pair: '42-USDT',
intent: 'sell',
side: 'exactIn',
amount: '1.5',
ledgers: ['infinite-mainnet'],
})
// Show quote.amountOut and quote.costs in your UI, then:
const handle = await sdk.easy.swap({ quoteId: quote.id })
if (handle.status === 'confirmed' || handle.status === 'failed') {
// Done — refresh reads on success
} else {
// Still running — ask until confirmed or failed
const status = await sdk.settlement.track(handle.id)
}| Step | Page |
|---|---|
| Connect / implement wallet | Wallet adapter |
| Whose balance to show | Whose wallet (owner) |
| Quote costs on screen | Fees and costs |
intent / side on the pair | Swaps |
| When to poll status | Settlement |
Related
| Goal | Start here |
|---|---|
Config (mode, wallet, ledgers) | Configuration |
| Live market data | Live |
| Chart / feed history windows | Chart windows · Activity feeds |
| All write modules | Write operations |
| Browser or server | Browser / SPA · Backend service |
| Full method list | Read operations · Reference |