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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@promokit/js

v2.0.9

Published

JavaScript SDK for PromoKit marketing infrastructure

Readme

@promokit/js

JavaScript SDK for PromoKit APIs - Marketing infrastructure for developers.

Installation

npm install @promokit/js

Quick Start

import { PromoClient } from '@promokit/js';

const promo = new PromoClient({
  apiKey: 'your-api-key'
});

// Add to waitlist
const entry = await promo.waitlist.create({
  projectId: 'your-project-id',
  email: '[email protected]'
});

// Submit testimonial
const testimonial = await promo.testimonial.submit({
  projectId: 'your-project-id',
  content: 'Amazing product!',
  author: 'John Doe',
  rating: 5
});

// Create changelog entry
const changelog = await promo.changelog.create({
  projectId: 'your-project-id',
  version: 'v1.2.0',
  title: 'New Features',
  content: 'We added some amazing new features...',
  changes: ['Dark mode', 'API improvements', 'Bug fixes']
});

Architecture

PromoKit uses a centralized architecture where all requests go through promokit.pro. This simplifies configuration and ensures reliable service delivery.

API Reference

PromoClient

const promo = new PromoClient({
  apiKey: 'your-api-key'
});

All API requests are routed through PromoKit's centralized infrastructure at https://promokit.pro.

Waitlist API

Create Entry

const entry = await promo.waitlist.create({
  projectId: 'project_123',
  email: '[email protected]',
  referralCode: 'FRIEND123', // optional
  metadata: { source: 'landing-page' } // optional
});

// Returns WaitlistEntry:
// {
//   id: string,
//   email: string,
//   position: number,
//   referralCode: string,
//   referralUrl: string,
//   createdAt: string,
//   metadata?: Record<string, any>
// }

Get Stats

const stats = await promo.waitlist.getStats('project_123');

// Returns WaitlistStats:
// {
//   totalSignups: number,
//   signupsToday: number,
//   signupsThisWeek: number,
//   referralStats: Array<{ referrer: string, count: number }>
// }

Export Entries

const entries = await promo.waitlist.export('project_123');
// Returns array of WaitlistEntry objects

Remove Entry

await promo.waitlist.remove('project_123', '[email protected]');

Testimonial API

Submit Testimonial

const testimonial = await promo.testimonial.submit({
  projectId: 'project_123',
  content: 'This product changed my life!',
  author: 'John Doe',
  role: 'CEO', // optional
  company: 'Acme Inc', // optional
  avatar: 'https://example.com/avatar.jpg', // optional
  rating: 5, // optional, 1-5 stars
  metadata: { source: 'email-campaign' } // optional
});

// Returns Testimonial:
// {
//   id: string,
//   content: string,
//   author: string,
//   role?: string,
//   company?: string,
//   avatar?: string,
//   rating?: number,
//   status: 'PENDING' | 'APPROVED' | 'REJECTED',
//   createdAt: string,
//   metadata?: Record<string, any>
// }

Get Testimonials

const result = await promo.testimonial.get('project_123', {
  limit: 10,
  offset: 0,
  status: 'APPROVED' // optional: 'PENDING', 'APPROVED', 'REJECTED'
});

// Returns:
// {
//   testimonials: Testimonial[],
//   pagination: {
//     total: number,
//     limit: number,
//     offset: number,
//     hasMore: boolean
//   }
// }

Approve/Reject Testimonials

// Approve a testimonial
await promo.testimonial.approve('testimonial_123');

// Reject a testimonial
await promo.testimonial.reject('testimonial_123');

Changelog API

Create Entry

const entry = await promo.changelog.create({
  projectId: 'project_123',
  version: 'v2.1.0',
  title: 'Major Update',
  content: 'We have released a major update with lots of new features...',
  changes: [
    'New dashboard design',
    'Performance improvements',
    'Bug fixes'
  ],
  publishedAt: '2024-01-15T10:00:00Z' // optional, defaults to now
});

// Returns ChangelogEntry:
// {
//   id: string,
//   version: string,
//   title: string,
//   content: string,
//   changes: string[],
//   publishedAt: string,
//   createdAt: string
// }

Get Changelog Entries

const result = await promo.changelog.get('project_123', {
  limit: 5,
  offset: 0
});

// Returns:
// {
//   entries: ChangelogEntry[],
//   pagination: {
//     total: number,
//     limit: number,
//     offset: number,
//     hasMore: boolean
//   }
// }

Subscribe to Updates

await promo.changelog.subscribe('project_123', '[email protected]');

Update Entry

const updated = await promo.changelog.update('entry_123', {
  title: 'Updated Title',
  content: 'Updated content...'
});

Delete Entry

await promo.changelog.delete('entry_123');

Error Handling

The SDK includes comprehensive error handling:

import { PromoError } from '@promokit/js';

try {
  const entry = await promo.waitlist.create({
    projectId: 'project_123',
    email: 'invalid-email'
  });
} catch (error) {
  if (error instanceof PromoError) {
    console.error('API Error:', error.details);
    console.error('Status:', error.apiError.status);
    console.error('Message:', error.apiError.message);
  } else {
    console.error('Network Error:', error.message);
  }
}

PromoError Properties

interface APIError {
  status: number;
  statusText: string;
  message: string;
  details: any;
  endpoint: string;
  timestamp: string;
}

class PromoError extends Error {
  apiError: APIError;
  constructor(apiError: APIError);
}

TypeScript Support

Full TypeScript definitions are included:

interface PromoConfig {
  apiKey: string;
}

interface WaitlistEntry {
  id: string;
  email: string;
  position: number;
  referralCode: string;
  referralUrl: string;
  createdAt: string;
  metadata?: Record<string, any>;
}

interface Testimonial {
  id: string;
  content: string;
  author: string;
  role?: string;
  company?: string;
  avatar?: string;
  rating?: number;
  status: 'PENDING' | 'APPROVED' | 'REJECTED';
  createdAt: string;
  metadata?: Record<string, any>;
}

interface ChangelogEntry {
  id: string;
  version: string;
  title: string;
  content: string;
  changes: string[];
  publishedAt: string;
  createdAt: string;
}

Node.js Example

const { PromoClient } = require('@promokit/js');

const promo = new PromoClient({
  apiKey: process.env.PROMOKIT_API_KEY
});

async function addToWaitlist(email, referralCode) {
  try {
    const entry = await promo.waitlist.create({
      projectId: process.env.PROMOKIT_PROJECT_ID,
      email,
      referralCode,
      metadata: {
        source: 'server-side',
        timestamp: new Date().toISOString()
      }
    });
  
    console.log(`Added ${email} to waitlist at position ${entry.position}`);
    return entry;
  } catch (error) {
    console.error('Failed to add to waitlist:', error.message);
    throw error;
  }
}

Next.js API Route Example

// pages/api/waitlist.js
import { PromoClient } from '@promokit/js';

const promo = new PromoClient({
  apiKey: process.env.PROMOKIT_API_KEY
});

export default async function handler(req, res) {
  if (req.method !== 'POST') {
    return res.status(405).json({ error: 'Method not allowed' });
  }

  const { email, referralCode } = req.body;

  try {
    const entry = await promo.waitlist.create({
      projectId: process.env.PROMOKIT_PROJECT_ID,
      email,
      referralCode,
      metadata: {
        ip: req.headers['x-forwarded-for'] || req.connection.remoteAddress,
        userAgent: req.headers['user-agent']
      }
    });

    res.status(200).json(entry);
  } catch (error) {
    console.error('Waitlist API error:', error);
    res.status(error.apiError?.status || 500).json({
      error: error.message || 'Internal server error'
    });
  }
}