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

nexflow-sdk

v1.0.1

Published

Official NexFlow SDK for metered API endpoints

Readme

nexflow-sdk

Official TypeScript SDK for NexFlow - metered API endpoints with built-in usage tracking and billing.

npm version

Installation

npm install nexflow-sdk

Quick Start

import { NexFlow } from 'nexflow-sdk';

const nf = new NexFlow({
  apiKey: process.env.NEXFLOW_API_KEY!
});

// Create a metered endpoint
const { endpoint } = await nf.endpoints.create({
  name: 'My API',
  upstreamUrl: 'https://api.example.com/v1/data',
  pricePerCall: '0.001', // USDC per call
  recipientAddress: '0xYourWallet...'
});

// Run a metered call
const result = await nf.run(endpoint.id, { query: 'hello' });
console.log(result.data);
console.log(`Charged: $${result.billing.pricePerCall} USDC`);

API Reference

new NexFlow(config)

Create a new NexFlow client.

const nf = new NexFlow({
  apiKey: 'nf_live_xxx',        // Required: Your API key
  baseUrl: 'https://...',       // Optional: Custom API URL
  timeout: 30000,               // Optional: Request timeout (ms)
});

nf.endpoints.create(request)

Create a new metered endpoint.

const { endpoint } = await nf.endpoints.create({
  name: 'OpenAI Proxy',
  upstreamUrl: 'https://api.openai.com/v1/chat/completions',
  pricePerCall: '0.01',         // USDC
  platformFeeBps: 200,          // 2% platform fee (optional)
  recipientAddress: '0x...',
  network: 'base',              // Optional, defaults to 'base'
});

nf.endpoints.list()

List all endpoints for your account.

const { endpoints } = await nf.endpoints.list();
for (const ep of endpoints) {
  console.log(ep.name, ep.pricePerCall);
}

nf.endpoints.summary(endpointId)

Get billing summary for an endpoint.

const summary = await nf.endpoints.summary('ep_xxx');
console.log(`Calls this month: ${summary.thisMonth.calls}`);
console.log(`Revenue: $${summary.thisMonth.creatorNet} USDC`);

nf.run(endpointId, payload, options?)

Execute a metered call through your endpoint.

const result = await nf.run('ep_xxx', { 
  prompt: 'Hello world' 
});

console.log(result.data);              // Upstream response
console.log(result.billing.pricePerCall); // "0.001"
console.log(result.usage.daily);       // 42 calls today

With upstream authentication:

const result = await nf.run('ep_xxx', payload, {
  upstreamAuth: 'Bearer sk-xxx'
});

nf.usage.summary()

Get usage summary for your account.

const usage = await nf.usage.summary();
console.log(`Plan: ${usage.plan.name}`);
console.log(`Today: ${usage.today.used}/${usage.plan.dailyLimit}`);
console.log(`Month: ${usage.month.used}/${usage.plan.monthlyLimit}`);

Error Handling

The SDK throws typed errors for different scenarios:

import { 
  NexFlow, 
  QuotaExceededError, 
  AuthenticationError,
  NotFoundError 
} from 'nexflow-sdk';

try {
  await nf.run('ep_xxx', payload);
} catch (error) {
  if (error instanceof QuotaExceededError) {
    console.log('Quota exceeded!');
    console.log(`Daily: ${error.usage.daily}/${error.limits.dailyLimit}`);
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof NotFoundError) {
    console.log('Endpoint not found');
  }
}

Response Types

RunResponse

interface RunResponse<T> {
  success: boolean;
  data: T;                    // Upstream response
  billing: {
    pricePerCall: string;     // "0.001"
    platformCut: string;      // "0.00002"
    creatorNet: string;       // "0.00098"
  };
  usage: {
    daily: number;
    monthly: number;
    dailyLimit: number;
    monthlyLimit: number;
  };
  meta: {
    endpointId: string;
    endpointName: string;
    upstreamStatus: number;
    responseTimeMs: number;
  };
}

UsageSummary

interface UsageSummary {
  plan: {
    name: string;
    dailyLimit: number;
    monthlyLimit: number;
  };
  today: { used: number; remaining: number };
  month: { used: number; remaining: number };
  topEndpoints?: Array<{
    endpointId: string;
    name: string;
    calls: number;
  }>;
}

Plans & Limits

| Plan | Daily Limit | Monthly Limit | |------|-------------|---------------| | Free | 1,000 | 10,000 | | Starter | 5,000 | 50,000 | | Pro | 25,000 | 250,000 | | Enterprise | 100,000 | 1,000,000 |

License

MIT