Products & Pricing API
Manage your product catalog and pricing models.
Product Methods
createProduct
Create a new product.
const product = await easy.createProduct({
name: "Premium Subscription",
description: "Monthly premium subscription with all features",
active: true,
metadata: {
category: "subscription",
tier: "premium",
},
images: ["https://example.com/product-image.jpg"],
url: "https://example.com/products/premium",
});
Parameters
data(object, required)name(string, required): Product namedescription(string, optional): Product descriptionactive(boolean, optional): Whether the product is activemetadata(object, optional): Custom metadataimages(string[], optional): Array of image URLsurl(string, optional): Product page URL
Returns
Promise<ApiResponse<ProductData>>;
getProduct
Get a product by ID.
const product = await easy.getProduct("prod_123");
Parameters
productId(string, required): The ID of the product
Returns
Promise<ApiResponse<ProductData>>;
getProducts
List all products with optional filtering.
// Get all products with pagination
const products = await easy.getProducts({
limit: 20,
offset: 0,
});
// Get specific products by ID
const specificProducts = await easy.getProducts({
ids: ["prod_123", "prod_456"],
});
Parameters
params(object, optional)ids(string[], optional): Filter by specific product IDslimit(number, optional): Maximum number of products to returnoffset(number, optional): Number of products to skip
Returns
Promise<ApiResponse<ProductData[]>>;
updateProduct
Update a product.
const updated = await easy.updateProduct("prod_123", {
description: "Updated description",
active: false,
});
Parameters
productId(string, required): The ID of the productdata(object, required): Fields to update
Returns
Promise<ApiResponse<ProductData>>;
archiveProduct
Archive a product.
await easy.archiveProduct("prod_123");
Parameters
productId(string, required): The ID of the product to archive
Returns
Promise<ApiResponse<void>>;
Price Methods
createPrice
Create a price for a product.
One-time price:
const price = await easy.createPrice({
product_id: "prod_123",
unit_amount: 9999, // $99.99 in cents
currency: "USD",
active: true,
description: "One-time purchase",
});
Recurring price:
const recurringPrice = await easy.createPrice({
product_id: "prod_123",
unit_amount: 2999, // $29.99 in cents
currency: "USD",
recurring: {
interval: "month",
interval_count: 1,
},
active: true,
description: "Monthly subscription",
});
Parameters
data(object, required)product_id(string, required): Product ID this price belongs tounit_amount(number, required): Price in centscurrency(string, required): Three-letter currency coderecurring(object, optional): Recurring billing configurationinterval(string, required): 'day', 'week', 'month', or 'year'interval_count(number, required): Number of intervals
active(boolean, optional): Whether the price is activedescription(string, optional): Price description
Returns
Promise<ApiResponse<PriceData>>;
getPrice
Get a price by ID.
const price = await easy.getPrice("price_123");
Parameters
priceId(string, required): The ID of the price
Returns
Promise<ApiResponse<PriceData>>;
getPrices
List all prices with optional filtering.
// Get all prices with pagination
const prices = await easy.getPrices({
limit: 20,
offset: 0,
});
// Get specific prices by ID
const specificPrices = await easy.getPrices({
ids: ["price_123", "price_456"],
});
Parameters
params(object, optional)ids(string[], optional): Filter by specific price IDslimit(number, optional): Maximum number of prices to returnoffset(number, optional): Number of prices to skip
Returns
Promise<ApiResponse<PriceData[]>>;
updatePrice
Update a price.
const updated = await easy.updatePrice("price_123", {
active: false,
description: "Deprecated pricing",
});
Parameters
priceId(string, required): The ID of the pricedata(object, required): Fields to update
Returns
Promise<ApiResponse<PriceData>>;
archivePrice
Archive a price.
await easy.archivePrice("price_123");
Parameters
priceId(string, required): The ID of the price to archive
Returns
Promise<ApiResponse<void>>;
getProductWithPrice
Get a product with a specific price.
const productWithPrice = await easy.getProductWithPrice(
"prod_123",
"price_456",
);
getProductWithPrices
Get a product with all its prices.
const productWithPrices = await easy.getProductWithPrices("prod_123");
Type Definitions
ProductData
interface ProductData {
id: string;
name: string;
description?: string;
active: boolean;
created_at: string;
updated_at: string;
metadata?: Record<string, unknown>;
images?: string[];
url?: string;
}
PriceData
interface PriceData {
id: string;
product_id: string;
unit_amount: number;
currency: string;
recurring?: {
interval: "day" | "week" | "month" | "year";
interval_count: number;
};
active: boolean;
description?: string;
created_at: string;
updated_at: string;
}