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

@callpaymin/sdk

v1.0.0

Published

Official JavaScript/TypeScript SDK for CallPayMin API - per-minute billing video calls, chat, and AI summaries

Readme

CallPayMin SDK

Official JavaScript/TypeScript SDK for the CallPayMin API. Build per-minute billing video calls, chat messaging, and AI summaries into your applications.

Installation

npm install @callpaymin/sdk
# or
yarn add @callpaymin/sdk
# or
pnpm add @callpaymin/sdk

Quick Start

import { CallPayMin } from '@callpaymin/sdk';

const client = new CallPayMin({
  apiKey: 'cpm_live_your_api_key',
});

// Create a user
const user = await client.users.create({
  externalId: 'user_123',
  displayName: 'John Doe',
  email: '[email protected]',
});

// Create an expert
const expert = await client.experts.create({
  externalId: 'expert_456',
  displayName: 'Dr. Smith',
  ratePerMinute: 5,
});

// Start a call with per-minute billing
const call = await client.calls.create({
  participants: [
    { externalId: 'user_123', displayName: 'John', role: 'client' },
    { externalId: 'expert_456', displayName: 'Dr. Smith', role: 'expert' },
  ],
  billing: {
    payerId: 'user_123',
    ratePerMinute: 5,
  },
});

Features

  • Video/Audio Calls - WebRTC-powered calls with TURN server support
  • Per-Minute Billing - Automatic billing based on call duration
  • Chat Messaging - Real-time chat with per-message billing
  • AI Summaries - Generate call/chat summaries using AI
  • Payment Methods - Stripe integration for card payments
  • Webhooks - Real-time event notifications

Payment Modes

Self-Managed Mode

You handle payments. We track virtual balances.

// Add funds after your own payment processing
await client.users.addFunds('user_123', {
  amount: 50,
  description: 'Deposit',
});

Managed Mode

CallPayMin handles Stripe payments for you.

// Create setup intent for card collection
const { clientSecret } = await client.users.createSetupIntent('user_123');

// Use clientSecret with Stripe.js on frontend
// After user adds card, save it:
await client.users.savePaymentMethod('user_123', {
  paymentMethodId: 'pm_xxx',
  setAsDefault: true,
});

// Charge user's card
await client.users.charge('user_123', {
  amount: 25,
  description: 'Consultation fee',
});

WebRTC Video Calls

Browser

import { CallPayMin, CallPayMinWebRTC } from '@callpaymin/sdk';

const client = new CallPayMin({ apiKey: 'cpm_live_xxx' });

const callClient = new CallPayMinWebRTC({
  client,
  onLocalStream: (stream) => {
    localVideo.srcObject = stream;
  },
  onRemoteStream: (stream) => {
    remoteVideo.srcObject = stream;
  },
  onStateChange: (state) => {
    console.log('Call state:', state);
  },
  onCallEnded: (call) => {
    console.log(`Duration: ${call.duration}s, Cost: $${call.billing.totalCost}`);
  },
});

// Start call
const call = await callClient.startCall({
  participants: [
    { externalId: 'user_123', displayName: 'John', role: 'client' },
    { externalId: 'expert_456', displayName: 'Dr. Smith', role: 'expert' },
  ],
  billing: {
    payerId: 'user_123',
    ratePerMinute: 5,
  },
});

// Controls
callClient.toggleAudio(false); // Mute
callClient.toggleVideo(false); // Camera off

// End call
await callClient.endCall();

React Native

npm install @callpaymin/sdk react-native-webrtc

See examples/react-native for full implementation.

Chat Messaging

// Create chat session
const chat = await client.chats.create({
  participants: [
    { externalId: 'user_123', displayName: 'John', role: 'client' },
    { externalId: 'expert_456', displayName: 'Dr. Smith', role: 'expert' },
  ],
  billing: {
    payerId: 'user_123',
    ratePerMinute: 2,
    freeTier: { messages: 10 },
  },
});

// Send message
const message = await client.chats.sendMessage(chat.id, {
  senderExternalId: 'user_123',
  content: 'Hello, I have a question...',
});

// Get messages
const messages = await client.chats.getMessages(chat.id);

// End chat
await client.chats.end(chat.id);

AI Summaries

// Generate summary for a call
const summary = await client.summaries.generateForCall('call_abc123', {
  type: 'detailed',
  includeActionItems: true,
  includeKeyPoints: true,
});

console.log(summary.content);
console.log(summary.actionItems);
console.log(summary.keyPoints);

// Generate summary for a chat
const chatSummary = await client.summaries.generateForChat('chat_xyz789');

Users & Experts

Users (Clients)

// Create user
const user = await client.users.create({
  externalId: 'user_123',
  displayName: 'John Doe',
  email: '[email protected]',
});

// Get balance
const { balance } = await client.users.getBalance('user_123');

// Get transactions
const transactions = await client.users.getTransactions('user_123');

// Payment methods (managed mode)
const methods = await client.users.getPaymentMethods('user_123');

Experts

// Create expert
const expert = await client.experts.create({
  externalId: 'expert_456',
  displayName: 'Dr. Smith',
  email: '[email protected]',
  specialties: ['cardiology'],
  ratePerMinute: 5,
});

// Update availability
await client.experts.setStatus('expert_456', 'available');

// Get earnings
const earnings = await client.experts.getEarnings('expert_456');
// { balance: 150, pendingPayout: 50, totalEarned: 1000 }

// Request payout
await client.experts.requestPayout('expert_456');

Organization & API Keys

// Get usage
const usage = await client.organization.getUsage();
// { callMinutes: { used: 150, limit: 1000 }, ... }

// Create API key
const { apiKey, key } = await client.organization.createApiKey({
  name: 'Production Server',
  scopes: ['calls:write', 'users:read'],
});
// Save `key` securely - it won't be shown again!

// Configure webhooks
await client.organization.configureWebhooks({
  url: 'https://yourapp.com/webhooks/callpaymin',
  events: ['call.started', 'call.ended', 'summary.completed'],
});

Webhooks

Configure webhooks to receive real-time notifications:

// Events: call.started, call.ended, summary.completed, billing.threshold_reached

Verify webhook signatures:

import crypto from 'crypto';

function verifySignature(payload, signature, secret) {
  const [timestamp, hash] = [
    signature.match(/t=(\d+)/)?.[1],
    signature.match(/v1=(\w+)/)?.[1],
  ];

  const signedPayload = `${timestamp}.${JSON.stringify(payload)}`;
  const expected = crypto.createHmac('sha256', secret).update(signedPayload).digest('hex');

  return crypto.timingSafeEqual(Buffer.from(hash), Buffer.from(expected));
}

Fee Structure (Managed Mode)

| Fee Type | Rate | When | |----------|------|------| | Platform Fee | 3.5% | On call/chat usage | | Expert Payout | 1.0% | When experts withdraw | | Business Payout | 1.0% | When you withdraw | | Stripe Card | 2.9% + $0.30 | Card charges | | Stripe Connect | 0.25% + $0.25 | Payouts |

No fees on deposits - only on usage.

API Reference

CallPayMin

new CallPayMin({
  apiKey: string,      // Your API key
  baseUrl?: string,    // API URL (default: https://api.callpaymin.com/v1)
  timeout?: number,    // Request timeout in ms (default: 30000)
})

Resources

  • client.users - User management
  • client.experts - Expert management
  • client.calls - Call sessions
  • client.chats - Chat sessions
  • client.summaries - AI summaries
  • client.organization - Org settings, API keys, webhooks

Examples

TypeScript Support

Full TypeScript support with exported types:

import type {
  User,
  Expert,
  Call,
  Chat,
  Summary,
  Transaction,
  PaymentMethod,
} from '@callpaymin/sdk';

Error Handling

try {
  await client.users.charge('user_123', { amount: 50 });
} catch (error) {
  if (error.code === 'CARD_DECLINED') {
    // Handle declined card
  } else if (error.code === 'INSUFFICIENT_BALANCE') {
    // Handle low balance
  } else {
    // Handle other errors
  }
}

Support

  • Documentation: https://docs.callpaymin.com
  • Email: [email protected]
  • GitHub Issues: https://github.com/callpaymin/sdk/issues

License

MIT