The TypeScript library provides convenient access to the Pandabase API from applications written in server-side TypeScript/JavaScript.
Installation
Install the package with:
bun add pandabase
pnpm add pandabase
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,
base_delay: 3000
max_delay: 250
},
sandbox: true,
});
Signatures
shops
await shop.retrieve("shop_");
products
list({ page_size: number, page_number: number })
await shop.products.list({ page_size: 10, page_number: 1 });
await shop.products.retrieve("prod_");
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",
});
await shop.products.delete("prod_");
coupons
list({ page_size: number, page_number: number })
await shop.coupons.list({ page_size: 10, page_number: 1 });
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",
});