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

revenue-cat-unofficial-client

v2.2.3

Published

Type-safe RevenueCat REST API v2 client for Node.js

Readme

revenue-cat-unofficial-client

Type-safe RevenueCat REST API v2 client for Node.js.

This is an unofficial, community-maintained client. Not affiliated with RevenueCat.

Covers endpoints from the RevenueCat v2 REST API.

Install

npm install revenue-cat-unofficial-client

Quick Start

import { RevenueCatClient } from 'revenue-cat-unofficial-client';

// From environment variables
// REVENUECAT_API_KEY=sk_...
// REVENUECAT_PROJECT_ID=proj_...
const client = RevenueCatClient.fromEnv();

// Or explicit
const client = new RevenueCatClient({
  apiKey: 'sk_...',
  projectId: 'proj_...',
});

API

Customers

// List customers
const { items } = await client.listCustomers({ limit: 20 });

// Get a customer
const customer = await client.getCustomer('customer-id-123');

// Create a customer
const customer = await client.createCustomer({
  id: 'user-123',
  attributes: [{ name: '$email', value: '[email protected]' }],
});

// Delete a customer
const deleted = await client.deleteCustomer('customer-id-123');

// Get customer subscriptions
const subs = await client.getCustomerSubscriptions('customer-id-123');

// Get customer purchases
const purchases = await client.getCustomerPurchases('customer-id-123');

// Get customer active entitlements
const entitlements = await client.getCustomerActiveEntitlements('customer-id-123');

Customer Actions

// Transfer customer to another
await client.transferCustomer('source-customer-id', {
  target_customer_id: 'target-customer-id',
  app_ids: ['app1', 'app2'],
});

// Grant entitlement
const updated = await client.grantEntitlement('customer-id', {
  entitlement_id: 'ent_123',
  expires_at: Date.now() + 30 * 24 * 60 * 60 * 1000,
});

// Revoke entitlement
await client.revokeEntitlement('customer-id', {
  entitlement_id: 'ent_123',
});

// Assign offering override
await client.assignOffering('customer-id', {
  offering_id: 'ofrng_123', // or null to clear
});

// Restore Google Play purchase by order ID
const restored = await client.restorePurchaseByOrderId('customer-id', {
  order_id: 'GPA.1234-5678-9012',
});

Customer Attributes

// Get attributes
const attrs = await client.getCustomerAttributes('customer-id');

// Set attributes
await client.setCustomerAttributes('customer-id', {
  attributes: [
    { name: '$email', value: '[email protected]' },
    { name: '$displayName', value: 'John Doe' },
    { name: 'custom_attr', value: 'value' }, // null to delete
  ],
});

Subscriptions

// Get subscription
const sub = await client.getSubscription('sub_123');

// Get subscription transactions
const txns = await client.getSubscriptionTransactions('sub_123', {
  sort: 'purchased_at',
  direction: 'desc',
});

// Get subscription entitlements
const entitlements = await client.getSubscriptionEntitlements('sub_123');

// Cancel (Web Billing subscription)
const updated = await client.cancelSubscription('sub_123');

// Extend subscription by days
const extended = await client.extendSubscriptionByDuration('sub_123', {
  extend_by_days: 14,
  extend_reason_code: 'customer_satisfaction',
});

// Extend subscription to date
const extended = await client.extendSubscriptionUntilDate('sub_123', {
  extend_until_ms: Date.now() + 30 * 24 * 60 * 60 * 1000,
  extend_reason_code: 'service_issue_or_outage',
});

// Refund (Web Billing subscription)
const refunded = await client.refundSubscription('sub_123');

// Refund specific transaction (Play Store)
const refunded = await client.refundSubscriptionTransaction('sub_123', 'GPA.0000-0000-0000');

// Get management URL
const { url } = await client.getSubscriptionAuthenticatedManagementUrl('sub_123');

Purchases

// Get purchase
const purchase = await client.getPurchase('purc_123');

// Get purchase entitlements
const entitlements = await client.getPurchaseEntitlements('purc_123');

// Refund (Web Billing purchase)
const refunded = await client.refundPurchase('purc_123');

Virtual Currencies

// Get customer balances
const balances = await client.getCustomerVirtualCurrencies('customer-id', {
  include_empty_balances: true,
});

// Create transaction
await client.createVirtualCurrencyTransaction('customer-id', {
  adjustments: { GLD: 100, SLVR: 50 },
  reference: 'achievement_unlock',
});

// Update balance (no transaction)
await client.updateVirtualCurrencyBalance('customer-id', {
  adjustments: { GLD: -10 },
});

Projects & Apps

// List projects
const { items: projects } = await client.listProjects();

// Get project
const project = await client.getProject(); // uses client's projectId

// List apps
const { items: apps } = await client.listApps();

Entitlements, Products, Offerings, Packages

// Entitlements
const { items: ents } = await client.listEntitlements();
const ent = await client.getEntitlement('ent_123');

// Products
const { items: prods } = await client.listProducts();
const prod = await client.getProduct('prod_123');

// Offerings
const { items: offrs } = await client.listOfferings();
const offr = await client.getOffering('ofrng_123');

// Packages
const pkg = await client.getPackage('pkge_123');

Convenience Helpers

// Check specific entitlement
const hasPro = await client.hasEntitlement('customer-id', 'pro_entitlement_id');

Error Handling

import { RevenueCatError, RevenueCatConfigError } from 'revenue-cat-unofficial-client';

try {
  await client.getCustomer('user-123');
} catch (err) {
  if (err instanceof RevenueCatError) {
    console.log(`API error ${err.statusCode}: ${err.body.message}`);
    console.log(`Error type: ${err.body.type}`);
    console.log(`Retryable: ${err.body.retryable}`);
  } else if (err instanceof RevenueCatConfigError) {
    console.log('Configuration error:', err.message);
  }
}

TypeScript

Full type definitions are included.

import {
  RevenueCatClient,
  type Customer,
  type Subscription,
  type Entitlement,
  type Product,
  type Purchase,
  type Invoice,
  type Project,
  type App,
  type Offering,
  type Package,
} from 'revenue-cat-unofficial-client';

Requirements

  • Node.js 18+

License

MIT