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

@swatbloc/sdk

v1.3.0

Published

SDK for SwatBloc headless commerce - access products, cart, and checkout

Readme

SwatBloc SDK

The official specific SDK for SwatBloc headless commerce. Access products, manage carts, handle checkout, and use custom databases directly from your frontend or backend application.

Installation

npm install @swatbloc/sdk

Quick Start

Initialize the client with your store's Public Key.

import { SwatBloc } from '@swatbloc/sdk';

// Initialize with your Public Key
const swat = new SwatBloc('pk_live_xxxxx');

Features

🛒 Commerce

Manage standard e-commerce flows.

// 1. List Products
const products = await swat.products.list({ limit: 10 });

// 2. Create Cart
const cart = await swat.cart.create([
  { productId: products[0].id, quantity: 1 }
]);

// 3. Checkout (Stripe Direct Charge)
// The user pays YOU directly. SwatBloc takes a platform fee automatically.
const checkout = await swat.checkout.create(cart.id, {
  successUrl: 'https://yoursite.com/success',
  cancelUrl: 'https://yoursite.com/cart'
});

// Redirect user to Stripe
window.location.href = checkout.url;

💾 Custom Databases (Virtual Tables)

Store structured data specific to your application (reviews, liability logs, customer preferences, etc.) without managing a separate backend.

1. Define Your Schema

You can define schemas programmatically (ideal for migrations or AI agents). This operation is idempotent (safe to run on every startup).

// Create a "Liability Waiver" collection
await swat.db.createModel(
  'Liability Waiver', // Display Name
  'liability-waivers', // Slug (Table Name)
  {
    fields: [
      { key: 'customer_email', type: 'text', required: true },
      { key: 'signed_at', type: 'date', required: true },
      { key: 'order_id', type: 'reference' }, // Links to external IDs
      { key: 'photo_evidence', type: 'image' }
    ]
  }
);

2. Write Data

Data is automatically validated against your schema before saving.

const waiver = await swat.db.collection('liability-waivers').create({
  customer_email: '[email protected]',
  signed_at: new Date().toISOString(),
  order_id: 'ord_123',
  photo_evidence: 'https://site-assets.swatbloc.com/signatures/sign_1.png'
});

3. Query Data

Filter your custom data.

const logs = await swat.db.collection('liability-waivers').list({
  limit: 5,
  filter: {
    customer_email: '[email protected]'
  }
});

📦 Orders (Admin)

Manage and track orders. Requires Secret Key (sk_live_...).

// Initialize with Secret Key
const swatAdmin = new SwatBloc('sk_live_xxxxx');

// 1. List Orders
const orders = await swatAdmin.orders.list({ status: 'pending' });

// 2. Get Order Details
const order = await swatAdmin.orders.get('order_123');

// 3. Update Status
await swatAdmin.orders.update('order_123', {
  status: 'shipped',
  fulfillment_status: 'fulfilled'
});

Type Safety

The SDK is fully typed.

import { Product, Cart, ContentItem } from '@swatbloc/sdk';

Get Your API Keys

  1. Go to your SwatBloc dashboard: https://swatbloc.com
  2. Navigate to SettingsDeveloper
  3. Generate a new API key
  4. Use the public key (pk_live_...) in your app

:)