Reads the site's published product catalogue. Accessible via lynkow.products.

Requires a publishable key: pass publishableKey to createClient(). Without a valid one, every call throws LynkowError UNAUTHORIZED (apiCode STOREFRONT_KEY_REQUIRED, STOREFRONT_KEY_INVALID or STOREFRONT_KEY_REVOKED). With cache: true, responses are cached for 5 minutes.

Access via: lynkow.products

Methods

2 methods

getBySlug

TypeScript
getBySlug(idOrSlug: string, options?: BaseRequestOptions & { country?: string; market?: string }): Promise<Product>

Fetches one published product by its prod_... id or its slug, with its variants and structuredData. With a locale, the slug can be the one of that locale, and an untranslated product is served in the closest available locale with isFallback: true. market and country work as in list(). Throws LynkowError NOT_FOUND (apiCode PRODUCT_NOT_FOUND) when the product is unknown, unpublished, hidden in the requested locale or market, or untranslated with fallback: false, and when the product catalogue is off for the site.

Parameter

Type

Description

idOrSlug

string

The product's prod_... id or its URL slug.

options

BaseRequestOptions & { country?: string; market?: string }

locale, fallback, market, country and fetchOptions.

Returns: Promise<Product>

TypeScript
const product = await lynkow.products.getBySlug('classic-tee', { locale: 'fr', country: 'FR' })
for (const variant of product.variants) {
  const label = variant.optionValues.map((ov) => ov.value).join(' / ')
  console.log(label, variant.priceGrossCents, variant.availability)
}

list

TypeScript
list(filters?: ProductsFilters, options?: BaseRequestOptions & { country?: string; market?: string }): Promise<ProductsListResponse>

Lists published products, newest first unless sortBy says otherwise. With a locale, an untranslated product is served in the closest available locale with isFallback: true, and fallback: false leaves it out. market leaves out the products hidden in that market, and country sets the VAT rate of standard products' prices. Throws LynkowError NOT_FOUND when the product catalogue is off for the site (apiCode PRODUCT_NOT_FOUND). While collections are enabled, it also throws NOT_FOUND for an unknown collection or category filter (PRODUCT_COLLECTION_NOT_FOUND, PRODUCT_CATEGORY_NOT_FOUND).

Parameter

Type

Description

filters

ProductsFilters

Optional ProductsFilters: pagination, search, collection, category, kind and sort.

options

BaseRequestOptions & { country?: string; market?: string }

locale, fallback, market, country and fetchOptions.

Returns: Promise<ProductsListResponse>

TypeScript
const { data, meta } = await lynkow.products.list(
  { category: 'kitchen', limit: 12 },
  { locale: 'de', country: 'DE' }
)