Skip to content
CTRL K
    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()
    
    StepWhat you do
    PackageWatch official channels for @nutrimatic/sdkInstallation
    InitPass ledgers, mode, and integrationContext
    Live readsCall sdk.live.watchPair / watchInstrument (Live)
    One-shot / historyeasy.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)
    }
    StepPage
    Connect / implement walletWallet adapter
    Whose balance to showWhose wallet (owner)
    Quote costs on screenFees and costs
    intent / side on the pairSwaps
    When to poll statusSettlement

    Related

    GoalStart here
    Config (mode, wallet, ledgers)Configuration
    Live market dataLive
    Chart / feed history windowsChart windows · Activity feeds
    All write modulesWrite operations
    Browser or serverBrowser / SPA · Backend service
    Full method listRead operations · Reference