The TypeScript library provides convenient access to the Pandabase API from applications written in server-side TypeScript/JavaScript.

Installation

Install the package with:

# Bun
bun add pandabase

# pnpm
pnpm add pandabase

# npm
npm install pandabase

Usage

The package needs to be configured with your api key, which is available in the api keys tab.

import Pandabase from "pandabase";

const pandabase = new Pandabase("tokn_", { ...options });

const shop = await pandabase.shops("shop_");

const products = await shop.products.list({ page: 1, page_size: 10 });

console.log(products);

Configuration

The package can be initialized with several options:

import Pandabase from "pandabase";

const pandabase = new Pandabase("tokn_", {
  idempotency_enabled: true,
  retries: {
    max_retries: 5, // default is 3
    base_delay: 3000 // 32000 default
    max_delay: 250 // default 250
  },
  sandbox: true, // If you want to use the sandbox instance
});

Signatures

shops

  • list()
  • retrieve(shopId)
await shop.retrieve("shop_");

products

  • list({ page_size: number, page_number: number })
await shop.products.list({ page_size: 10, page_number: 1 });
  • retrieve(productId)
await shop.products.retrieve("prod_");
  • retrieveByHandle(handle)
await shop.products.retrieveByHandle("handle");
  • create({ CreateProductRequestBody })
await shop.products.create({
  title: "Product",
  subtitle: "Product subtitle",
  description: "A very long description",
  price: 500,
  currency: "USD",
  type: "SERIAL",
  handle: "handle",
});
  • update(productId, { UpdateProductRequestBody })
await shop.products.update("prod_", {
  name: "New product name",
  handle: "new-handle",
});
  • delete(productId)
await shop.products.delete("prod_");

coupons

  • list({ page_size: number, page_number: number })
await shop.coupons.list({ page_size: 10, page_number: 1 });
  • retrieve(couponId)
await shop.coupons.retrieve("cpn_");
  • create({ CreateCouponRequestBody })
await shop.coupons.create({
  name: "Summer sale 2025",
  type: "PERCENTAGE",
  code: "SUMMER SALE",
  value: 10,
  limit: 5,
  limited: false,
});
  • update(couponId, { UpdateCouponRequestBody })
await shop.coupons.update("cpn_", {
  name: "Summer sale 2025",
});