Reads the site's product collections. Accessible via lynkow.productCollections.

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

Access via: lynkow.productCollections

Methods

2 methods

getBySlug

TypeScript
getBySlug(slug: string, options?: BaseRequestOptions & { market?: string }): Promise<ProductCollection>

Fetches one product collection by its slug, with its structuredData (render it with renderJsonLdGraph()). Takes the slug only, never a col_... id. With a locale, the slug can be the one of that locale, and an untranslated collection is served in the closest available locale with isFallback: true. Throws LynkowError NOT_FOUND (apiCode PRODUCT_COLLECTION_NOT_FOUND) for an unknown slug, for an untranslated collection with fallback: false, and when collections are off for the site.

Parameter

Type

Description

slug

string

The collection's URL slug (e.g. 'summer').

options

BaseRequestOptions & { market?: string }

locale, fallback, market and fetchOptions.

Returns: Promise<ProductCollection>

TypeScript
import { renderJsonLdGraph } from 'lynkow'

const collection = await lynkow.productCollections.getBySlug('summer', { locale: 'fr' })
// <div dangerouslySetInnerHTML={{ __html: renderJsonLdGraph(collection.structuredData?.graph) }} />

list

TypeScript
list(filters?: ProductCollectionsFilters, options?: BaseRequestOptions): Promise<ProductCollectionsListResponse>

Lists the site's product collections, sorted by their untranslated title. With a locale, an untranslated collection is served in the closest available locale with isFallback: true, and fallback: false leaves it out. Throws LynkowError NOT_FOUND (apiCode PRODUCT_COLLECTION_NOT_FOUND) when collections are off for the site.

Parameter

Type

Description

filters

ProductCollectionsFilters

Optional ProductCollectionsFilters: page and limit.

options

BaseRequestOptions

locale, fallback and fetchOptions.

Returns: Promise<ProductCollectionsListResponse>

TypeScript
const { data, meta } = await lynkow.productCollections.list({ page: 1, limit: 20 }, { locale: 'fr' })