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

@pionts/sdk

v1.0.1

Published

Official server-side SDK for the Pionts loyalty & rewards platform. Integrate points, referrals, and discount redemptions into any e-commerce shop with a single import.

Readme

@pionts/sdk

Official server-side SDK for the Pionts loyalty & rewards platform. Add points, referrals, and discount code redemptions to any e-commerce shop.

Installation

npm install @pionts/sdk

Quick Start

import { PiontsClient } from '@pionts/sdk';

const pionts = new PiontsClient({
  apiUrl: 'https://your-pionts-instance.com',
  secretKey: 'sk_live_...',
});

// Validate a loyalty discount code at checkout
const result = await pionts.checkout.validate('CODE-123');
if (result.valid) {
  console.log(`Discount: ${result.discountAmount}`);
}

// Award points after payment
await pionts.orders.paid({
  orderId: 'ORD-001',
  email: '[email protected]',
  orderTotal: 99.99,
  currency: 'EUR',
});

// Mark discount code as used
await pionts.checkout.markUsed('CODE-123');

API Reference

PiontsClient

const pionts = new PiontsClient({
  apiUrl: string,      // Pionts API base URL
  secretKey: string,   // Secret API key (sk_live_...)
  timeout?: number,    // Request timeout in ms (default: 10000)
});

Checkout

// Validate a discount code
const result = await pionts.checkout.validate(code);
// Returns: { valid: boolean, discountAmount?: number, alreadyUsed?: boolean }

// Mark a code as used after successful payment
await pionts.checkout.markUsed(code, orderId?);
// Returns: { success: boolean }

Orders

// Notify that an order was paid (awards loyalty points)
await pionts.orders.paid({
  orderId: string,
  email: string,
  customerName?: string,
  orderTotal: number,
  currency?: string,
  referralCode?: string,
});

// Notify that an order was refunded (reverses points)
await pionts.orders.refunded(orderId, refundAmount?);

Customers

// Get customer balance, history, and profile
const customer = await pionts.customers.get('[email protected]');
// Returns: { found, points_balance, points_earned_total, referral_code, history, ... }

// Redeem points for a discount code
const result = await pionts.customers.redeem('[email protected]', 100);
// Returns: { discount_code, discount_amount, new_balance }

// Cancel a redemption (refund points)
await pionts.customers.cancelRedemption('[email protected]', '123');
// Returns: { points_returned, new_balance }

Config

// Get project configuration (earn actions, tiers, settings)
const config = await pionts.config.get();

Widget

// Generate HMAC initialization data for the frontend widget
const init = await pionts.widget.init('[email protected]', 'John');
// Returns: { projectKey, hmac, apiBase, email, name }

Webhook Verification

Verify incoming webhook signatures from Pionts:

import { PiontsWebhook } from '@pionts/sdk';

app.post('/webhooks/pionts', (req, res) => {
  const signature = req.headers['x-pionts-signature'];
  const isValid = PiontsWebhook.verify(req.rawBody, signature, webhookSecret);

  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }

  // Process the webhook event
  const { event, data } = req.body;
  // ...
});

Error Handling

import { PiontsError, PiontsTimeoutError } from '@pionts/sdk';

try {
  await pionts.checkout.validate('CODE-123');
} catch (err) {
  if (err instanceof PiontsTimeoutError) {
    console.log('Request timed out');
  } else if (err instanceof PiontsError) {
    console.log(`API error ${err.statusCode}: ${err.message}`);
  }
}

Features

  • Zero dependencies — only uses native fetch
  • TypeScript-first — full type definitions included
  • Built-in retry — automatic single retry on 5xx errors
  • Configurable timeout — default 10s with AbortController
  • Dual format — ESM and CommonJS support
  • Webhook verification — HMAC-SHA256 with timing-safe comparison

Requirements

  • Node.js >= 18 (uses native fetch)

License

MIT