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

@openrai/raiflow-sdk

v2.4.2

Published

Business runtime SDK for RaiFlow

Readme

@openrai/raiflow-sdk

Typed JavaScript and TypeScript client for the RaiFlow runtime.

Install

pnpm add @openrai/raiflow-sdk

Quick Start

import { RaiFlowClient } from '@openrai/raiflow-sdk';

const client = RaiFlowClient.initialize({
  baseUrl: 'http://127.0.0.1:3100',
  apiKey: process.env['RAIFLOW_API_KEY']!,
});

const health = await client.system.health();
console.log(health.status);

API Reference

RaiFlowClient

Main entrypoint for the SDK.

const client = RaiFlowClient.initialize({
  baseUrl: 'http://127.0.0.1:3100',  // required
  apiKey: 'your-secret-key',          // required
  basePath: '/api',                   // optional, default: "/api"
});

Resource accessors:

  • client.accountsAccountsResource
  • client.blocksBlocksResource
  • client.invoicesInvoicesResource
  • client.sendsSendsResource
  • client.systemSystemResource
  • client.webhooksWebhooksResource
  • client.workWorkResource

AccountsResource

Create and operate managed and watched accounts.

createManaged(options)

Create a custodial managed account. RaiFlow derives the address, holds the keys, and handles signing.

const account = await client.accounts.createManaged({
  label: 'Primary wallet',
  representative: 'nano_1...',      // optional
  idempotencyKey: 'create-primary', // optional but recommended
});

createWatched(options)

Create a watched account for an external address you do not control.

const account = await client.accounts.createWatched({
  address: 'nano_1...',
  label: 'Exchange deposit',
});

list(options?)

List all accounts. Optionally filter by type.

const { data } = await client.accounts.list();
const managed = await client.accounts.list({ type: 'managed' });

get(id)

Fetch a single account by ID.

const account = await client.accounts.get('acc_...');

update(id, patch)

Update an account's label or representative.

const updated = await client.accounts.update('acc_...', {
  label: 'New label',
  representative: 'nano_1...',
});

receivable(id)

Fetch pending receivable blocks for the account's address from the connected Nano node.

const { data } = await client.accounts.receivable('acc_...');

InvoicesResource

Create payment expectations and track their lifecycle.

Invoices require custodial mode. Non-custodial runtimes reject these requests with HTTP 501.

create(options, idempotencyKey?)

Create a new invoice. The idempotencyKey header is sent automatically when provided.

const invoice = await client.invoices.create(
  {
    recipientAccount: 'acc_...',
    expectedAmountRaw: '1000000000000000000000000000000',
    expiresAt: '2026-12-31T23:59:59Z',      // optional
    metadata: { orderId: '123' },            // optional
    completionPolicy: { type: 'exact' },     // optional: "exact" | "at_least"
  },
  'invoice-order-123',                       // optional idempotency key
);

get(id)

Fetch a single invoice.

const invoice = await client.invoices.get('inv_...');

list(options?)

List invoices. Optionally filter by status.

const { data } = await client.invoices.list();
const pending = await client.invoices.list({ status: 'pending' });

cancel(id)

Cancel a pending invoice.

const cancelled = await client.invoices.cancel('inv_...');

listPayments(id)

List payments matched to an invoice.

const { data } = await client.invoices.listPayments('inv_...');

listEvents(id, options?)

List events for an invoice, optionally paginated with after.

const { data } = await client.invoices.listEvents('inv_...');
const later = await client.invoices.listEvents('inv_...', { after: 'evt_...' });

SendsResource

Queue and track outgoing transfers.

Sends require custodial mode. Non-custodial runtimes reject these requests with HTTP 501.

queue(accountId, options)

Queue a send from a managed account. Requires an idempotencyKey.

const send = await client.sends.queue('acc_...', {
  destination: 'nano_1...',
  amountRaw: '1000000000000000000000000000000',
  idempotencyKey: 'send-order-456',
});

listByAccount(accountId)

List sends for a specific account.

const { data } = await client.sends.listByAccount('acc_...');

get(id)

Fetch a single send by its global ID.

const send = await client.sends.get('snd_...');

WebhooksResource

Register webhook endpoints for event delivery.

create(options)

Register a new webhook endpoint.

const endpoint = await client.webhooks.create({
  url: 'https://example.com/webhooks/raiflow',
  eventTypes: ['invoice.completed', 'send.confirmed'],
  secret: 'whsec_...', // optional
});

list()

List all registered webhook endpoints.

const { data } = await client.webhooks.list();

delete(id)

Remove a webhook endpoint.

await client.webhooks.delete('whk_...');

SystemResource

health()

Check runtime health.

const health = await client.system.health();
// => { status: "ok" }

BlocksResource

Low-level block publishing for pre-signed blocks.

This is an escape hatch for non-custodial flows where blocks are signed client-side (e.g., a browser wallet or thin client). For custodial flows, use SendsResource — RaiFlow handles signing and PoW automatically.

publish(block)

Publish a pre-signed block JSON string to the network.

const result = await client.blocks.publish('{"block":"..."}');
// => { hash: "ABC123..." }

WorkResource

Low-level work generation for non-custodial flows.

If you find yourself using this directly, it usually indicates a missing SDK feature. For custodial flows, RaiFlow generates work automatically.

generate(hash, difficulty?, blockType?)

Generate proof-of-work for a block hash.

const result = await client.work.generate('ABC123...');
// => { work: "1f0e2d..." }

const withDifficulty = await client.work.generate('ABC123...', 'fffffff800000000');
const receiveWork = await client.work.generate('ABC123...', undefined, 'receive');

Re-exported Types

The SDK re-exports all canonical types from @openrai/model so you do not need to install it separately:

import type {
  Invoice,
  InvoiceStatus,
  Payment,
  PaymentStatus,
  Account,
  AccountType,
  Receivable,
  Send,
  SendStatus,
  RaiFlowEvent,
  RaiFlowEventType,
  CompletionPolicy,
  WebhookEndpoint,
  CreateInvoiceRequest,
  CreateAccountRequest,
  WatchAccountRequest,
  UpdateAccountRequest,
  SendRequest,
  PublishBlockRequest,
  WorkGenerateRequest,
  CreateWebhookRequest,
  EventQueryOptions,
  PaginatedEventsResponse,
  RaiFlowError,
} from '@openrai/raiflow-sdk';

Re-exported Helpers

Webhook signature verification and signing helpers from @openrai/webhook:

import { verifySignature, signPayload } from '@openrai/raiflow-sdk';

const isValid = verifySignature(payload, signature, secret);
const signature = signPayload(payload, secret);

Related Packages

Notes

  • The SDK targets the RaiFlow runtime API, not raw Nano JSON-RPC.
  • All mutating operations accept an idempotency key where the runtime expects one. Sends require an idempotency key — missing it results in rejection.
  • @openrai/nano-core remains a separate lower-level package and repo.

Docs

  • Repository: https://github.com/OpenRai/RaiFlow
  • Examples: https://github.com/OpenRai/RaiFlow/tree/main/examples