Skip to content
Branko Conjic edited this page Feb 8, 2024 · 2 revisions

getPrice

Retrieves the price with the given ID.

Usage

import { type Price, getPrice } from '@lemonsqueezy/lemonsqueezy.js';

const priceId = 234567;
const { statusCode, error, data } = await getPrice(priceId);

With related resources:

import { type GetPriceParams, type Price, getPrice } from '@lemonsqueezy/lemonsqueezy.js';

const priceId = 234567;
const { statusCode, error, data } = await getPrice(priceId, { include: ['variant'] });

Type Declarations

/**
 * Retrieve a price.
 *
 * @param priceId The given price id.
 * @param [params] (Optional) Additional parameters.
 * @param [params.include] (Optional) Related resources.
 * @returns A price object.
 */
declare function getPrice(priceId: number | string, params?: GetPriceParams): Promise<FetchResponse<Price>>;

Returns

Returns a price object.

{
	statusCode: number | null;
	error: Error | null;
	data: Price | null;
}

Source

Source ~ Type ~ Test

listVariants

Returns a paginated list of prices.

Usage

import { type ListPrices, listPrices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listPrices();

With filter:

import { type ListPrices, type ListPricesParams, listPrices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listPrices({ filter: { variantId: 234567 } });

With pagination:

import { type ListPrices, type ListPricesParams, listPrices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listPrices({ page: { number: 1, size: 10 } });

With related resources:

import { type ListPrices, type ListPricesParams, listPrices } from '@lemonsqueezy/lemonsqueezy.js';

const { statusCode, error, data } = await listPrices({ include: ['variant'] });

Type Declarations

/**
 * List all prices.
 *
 * @param [params] (Optional) Additional parameters.
 * @param [params.filter] (Optional) Filter parameters.
 * @param [params.filter.variantId] Only return prices belonging to the variant with this ID.
 * @param [params.page] (Optional) Custom paginated queries.
 * @param [params.page.number] (Optional) The parameter determine which page to retrieve.
 * @param [params.page.size] (Optional) The parameter to determine how many results to return per page.
 * @param [params.include] (Optional) Related resources.
 * @returns A paginated list of price objects ordered by `created_at` (descending).
 */
declare function listPrices(params?: ListPricesParams): Promise<FetchResponse<ListPrices>>;

Returns

Returns a paginated list of price objects ordered by created_at (descending).

{
	statusCode: number | null;
	error: Error | null;
	data: ListPrices | null;
}

Source

Source ~ Type ~ Test

Clone this wiki locally