npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@finatic/server-node

v1.0.8

Published

Node.js SDK for Finatic Server API

Readme

Finatic Server SDK (Node)

Node.js SDK for embedding Finatic in your backend. Keep the company API key on the server. Mint a 90-second one-time token for @finatic/client, or start a session and redirect to Connect.

Install

npm install @finatic/server-node

Quick start

import { FinaticServer } from '@finatic/server-node';

const finatic = new FinaticServer(process.env['FINATIC_API_KEY']!, {
  apiEnvironment: 'sandbox',
});

// Client iframe: 90-second token. Never send the API key to the browser.
const oneTimeToken = await finatic.v1.getToken();

// Redirect flow: start a session first (getPortalUrl requires it).
const redirectSession = await finatic.v1.startSession();
if (!redirectSession.session_id) {
  const message =
    'error' in redirectSession && redirectSession.error
      ? redirectSession.error
      : 'Session start failed';
  throw new Error(message);
}
const portalUrl = await finatic.v1.getPortalUrl({ mode: 'dark' });

// After account.grant.created, start a session for that portal user, then read.
const portalUserId = 'user-from-connect-onSuccess';
const authenticatedSession = await finatic.v1.startSession({ userId: portalUserId });
if (!authenticatedSession.authenticated) {
  const message = authenticatedSession.error
    ? authenticatedSession.error
    : `Session is ${authenticatedSession.status ?? 'not active'}`;
  throw new Error(message);
}

interface AccountSummary {
  accountId: string;
}

const accounts = await finatic.v1.listAccounts<AccountSummary[]>({
  includeSyncStatus: true,
});
const accountId = accounts.data?.[0]?.accountId;
if (!accountId) {
  throw new Error(accounts.errors[0]?.message ?? 'No granted accounts yet');
}
const orders = await finatic.v1.listOrders({ accountId });

Server v1 data methods return { traceId, data, warnings, errors }. Check errors before using data.

Error handling

Each normalized v1 error exposes two identifiers:

  • category is one of the stable generic categories, such as CONFLICT, VALIDATION, or RATE_LIMITED. Branch on this field for broad handling and retry policy.
  • code preserves the specific API-provided string, such as IDEMPOTENCY_KEY_REUSED. Codes are open-ended so SDK consumers can handle current and future API errors without losing identity.

When an API response has no usable code, the SDK falls back to the derived category. Existing FinaticV1ErrorCode imports remain valid as the public type for the open string code, while FinaticV1ErrorCategory represents the closed generic taxonomy.

fntc_sandbox_ keys use Finatic synthetic data. Broker paper/sim accounts stay live.

FinaticServer.init(apiKey, userId?) is a shortcut that calls startSession. Use the constructor + getToken() when you only need to hand a token to the browser.

Exact instrument descriptors

Order legs, fills, events, and positions use generated descriptor types by default. Exact futures remain distinct from product-root-only identities, and the SDK does not infer missing contract, expiry, venue, provenance, or identity-quality fields.

const orders = await finatic.v1.listOrders({ accountId: 'acct_123' });
const instrument = orders.data?.[0]?.legs?.[0]?.instrument;

if (instrument?.future?.identityQuality === 'EXACT') {
  console.log(instrument.future.contractCode); // e.g. MGCZ6
}

await finatic.v1.createAccountOrder({
  accountId: 'acct_123',
  idempotencyKey: crypto.randomUUID(),
  body: {
    order: {
      finaticInstrumentId: 'finatic:future:MGCZ6',
      instrumentId: 418, // provider-native identifiers remain additive
    },
  },
});

Embed Connect

  1. v1.getToken() → pass the token to FinaticConnect.init(token) in the browser (token TTL is 90 seconds).
  2. Or v1.startSession() then v1.getPortalUrl(...) → redirect. Treat the full URL as secret.

Wait for webhook account.grant.created before treating access as durable.

startSession().success means the request completed. Check authenticated before account or trading calls; status, user_id, provided_user_id_rejected, and portal_connection_management_pending explain non-active session states.

Common commands

| Task | Command | | ---------- | -------------------- | | Build | npm run build | | Test | npm test | | Lint | npm run lint | | Type check | npm run type:check |

Documentation

This README is the Node SDK contract. Fetch the rest before writing a full integration: