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

@sellersmith/printway-sdk

v1.0.0

Published

Node.js SDK for the Printway Print-on-Demand Fulfillment API

Readme

Printway SDK

Node.js / TypeScript SDK for the Printway Print-on-Demand Fulfillment API (v3).

Installation

npm install @sellersmith/printway-sdk

Quick Start

import { Printway } from "@sellersmith/printway-sdk";

const printway = new Printway({
  accessToken: "your-pw-access-token",
  refreshToken: "your-refresh-token", // Optional — enables auto-refresh on 401
});

// List all products
const products = await printway.products.list();
console.log(products.data);

Configuration

const printway = new Printway({
  accessToken: "your-pw-access-token", // Required
  refreshToken: "your-refresh-token",  // Optional — auto-refresh on 401
  baseUrl: "https://apis.printway.io/v3", // Optional, default
  timeout: 30000,        // Optional, ms (default: 30000)
  enableLogging: false,  // Optional (default: false)
  useBearerAuth: false,  // Optional — use Authorization: Bearer header instead of pw-access-token
});

// Listen for token refresh events
printway.onTokenRefresh((newAccessToken, newRefreshToken) => {
  // Persist new tokens to your storage
});

API Reference

Authentication

// Generate token with email/password
const auth = await printway.auth.generateToken({
  email: "[email protected]",
  password: "your-password",
});

// Regenerate token
const newAuth = await printway.auth.regenerateToken({
  email: "[email protected]",
  password: "your-password",
});

// Refresh access token
const refreshed = await printway.auth.refreshToken("your-refresh-token");

// Destroy/revoke token
await printway.auth.destroyToken();

Products

// List all products (paginated)
const products = await printway.products.list({ limit: 10, page: 1 });

// Get product detail by code
const product = await printway.products.detail("PRODUCT_CODE");

// List SKU catalogs
const catalogs = await printway.products.listSkuCatalogs();

// Get shipping methods for variants
const shipping = await printway.products.getShippingMethods({
  variant_id: ["10024433"],
  sku: [],
});

Orders

// List orders (date range required)
const orders = await printway.orders.list({
  created_at_min: "2025-01-01 00:00:00",
  created_at_max: "2025-12-31 23:59:59",
  limit: 10,
  page: 1,
});

// Get order detail
const order = await printway.orders.detail({
  order_id: "YOUR_ORDER_ID",
  date: "2025-01-01",
});

// Create order
const newOrder = await printway.orders.create({
  order_id: "ORDER-001",
  firstName: "John",
  lastName: "Doe",
  shipping_email: "[email protected]",
  shipping_phone: "1234567890",
  shipping_address1: "123 Main St",
  shipping_city: "Miami",
  shipping_zip: "33101",
  shipping_province: "Florida",
  shipping_province_code: "FL",
  shipping_country: "United States",
  shipping_country_code: "US",
  shipping_service: "US",
  order_items: [{
    product_name: "Suncatcher Night Light Box",
    variant_title: "8X8 INCHES/MONOCHROME",
    item_sku: "PW-SNLB-8X8 INCHES-MONOCHROME",
    variant_id: "10024433",
    made_in_location: "VN",
    product_location: "PW-2",
    unfulfill_quantity: 1,
    artwork_front: "https://example.com/front.png",
  }],
});

// Calculate price before ordering
const price = await printway.orders.calculatePrice({
  shipping_country_code: "US",
  shipping_province_code: "California",
  shipping_service: "US",
  order_items: [{
    item_sku: "PW-SNLB-8X8 INCHES-MONOCHROME",
    variant_id: "10024433",
    made_in_location: "VN",
    product_location: "PW-2",
    quantity: 1,
  }],
});

// Cancel, delete, or pay orders
await printway.orders.cancel({ order_id: "ORDER-001" });
await printway.orders.delete({ order_id: "ORDER-001" });
await printway.orders.pay({ order_id: "ORDER-001" });

Webhooks

Supports two webhook types: "tracking" and "order".

// List webhooks
const trackingWebhooks = await printway.webhooks.list("tracking");
const orderWebhooks = await printway.webhooks.list("order");

// Create webhook
await printway.webhooks.create("tracking", {
  endpoint: "https://your-site.com/api/tracking-webhook",
  status: 1,
});

// Update webhook
await printway.webhooks.update("order", {
  endpoint: "https://your-site.com/api/order-webhook",
  status: 1,
});

// Delete webhook
await printway.webhooks.delete("tracking");

Transactions

// List transactions
const transactions = await printway.transactions.list({
  created_at_min: "2025-01-01 00:00:00",
  created_at_max: "2025-12-31 23:59:59",
  limit: 10,
  page: 1,
});

// List transactions for a specific order
const orderTransactions = await printway.transactions.orderList({
  order_id: "ORDER-001",
  date: "2025-01-01",
});

Error Handling

import { Printway, PrintwayError } from "@sellersmith/printway-sdk";

try {
  const products = await printway.products.list();
} catch (error) {
  if (error instanceof PrintwayError) {
    console.error(`API Error ${error.status}: ${error.message}`);
    console.error("Response:", error.responseBody);
  }
}

Auto Token Refresh

When refreshToken is provided, the SDK automatically refreshes the access token on 401 responses and retries the request:

const printway = new Printway({
  accessToken: "your-access-token",
  refreshToken: "your-refresh-token",
});

// Optionally listen for token updates to persist them
printway.onTokenRefresh((newAccessToken, newRefreshToken) => {
  // Save to database, env, etc.
});

Requirements

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

License

MIT