Skip to main content
The @crevio/sdk package provides a type-safe TypeScript client for the Crevio API. It works in Node.js, browsers, Cloudflare Workers, and Deno.

Installation

npm install @crevio/sdk

Quick start

import { Crevio } from "@crevio/sdk";

const crevio = new Crevio({
  security: {
    apiKey: "YOUR_API_TOKEN",
  },
});

Usage examples

List products

const { items } = await crevio.products.list();

for (const product of items) {
  console.log(product.name, product.prefixId);
}

Get a product

const product = await crevio.products.get({
  prefixId: "prd_abc123",
});

Create a checkout

const checkout = await crevio.checkouts.create({
  checkout: {
    checkoutItemsAttributes: [
      {
        priceVariantId: 1,
        quantity: 1,
      },
    ],
  },
});

List orders with expanded data

const { items, pagination } = await crevio.orders.list({
  expand: "line_items,customer",
  page: 1,
  limit: 50,
});

Create a customer

const customer = await crevio.customers.create({
  customer: {
    email: "customer@example.com",
    firstName: "Jane",
    lastName: "Doe",
  },
});

Create a discount

const discount = await crevio.discounts.create({
  discount: {
    code: "SUMMER20",
    discountType: "percent_off",
    percentOff: 20,
    duration: "once",
    maxRedemptions: 100,
  },
});

Error handling

The SDK throws typed errors that you can catch:
try {
  const product = await crevio.products.get({
    prefixId: "prd_nonexistent",
  });
} catch (error) {
  if (error.statusCode === 404) {
    console.log("Product not found");
  }
}

Runtime support

RuntimeSupported
Node.js 18+Yes
BrowsersYes
Cloudflare WorkersYes
DenoYes
BunYes
The SDK is generated with Speakeasy and includes Zod validation, automatic retries, and full TypeScript type definitions.