TypeScript SDK

The LiquidTCG SDK provides a type-safe client for all v1 API endpoints. Built with full TypeScript support, ESM + CJS outputs.

Installation

pnpm install @buylist-saas/sdk

(Package publishing is pending — use the bundled SDK from the repo for now.)

Usage

import { BuylistClient } from "@buylist-saas/sdk";

const client = new BuylistClient({
  apiKey: process.env.BUYLIST_API_KEY!,
  baseUrl: "https://your-store.liquidtcg.co/api/v1",
});

// List submissions
const submissions = await client.submissions.list({ status: "pending_review" });

// Create a submission
const created = await client.submissions.create({
  customer_email: "customer@example.com",
  customer_name: "Jane Smith",
  card_list: "4x Counterspell NM",
  notes: "Interested in store credit",
}, { idempotencyKey: "unique-request-id" });

// Transition state
await client.submissions.transition(created.id, { action: "approve" });

// Webhooks
const webhook = await client.webhooks.create({
  url: "https://yoursite.com/webhook",
  events: ["submission.received", "submission.completed"],
});
console.log("Signing secret:", webhook.secret);

Error handling

import { BuylistError } from "@buylist-saas/sdk";

try {
  await client.submissions.transition("invalid-id", { action: "reject" });
} catch (err) {
  if (err instanceof BuylistError) {
    console.error(err.code, err.message, err.status);
    // e.g. "NOT_FOUND", "Submission not found", 404
  }
}

Customer sessions

// Issue a token for a customer to submit on their own
const session = await client.customerSessions.create({
  customer_email: "customer@example.com",
});
// Pass session.token to your frontend — it works as a Bearer token for POST /submissions