Sleek’s Web Extension SDK can extract product information from the pages your users are visiting. To enable this experience for your users, you’ll need to call Sleek on the pages that you want to extract product information from. This documentation will guide you through the integration process.
This document assumes that you have already integrated the Sleek web extension SDK into your extension. If you haven’t, please refer to the Web Extension SDK integration guide.

Enable product extraction

After Sleek Web Extension is installed and setup in your extension, you are ready to extract product information from the pages your users are visiting. To extract product information from a page, you can use the unified extractProducts method which will automatically determine the page type and extract the appropriate product information:
import { getWebExtSdk } from "@sleek/web-ext-sdk";

const products = await getWebExtSdk().onTab(tabId).extractProducts(); // Returns Promise<ExtractProductsResult>

// With options
const productsWithCategory = await getWebExtSdk().onTab(tabId).extractProducts({
  includeCategory: true
});
The extractProducts method returns an object based on the type of page:
  • For cart pages, it returns:
{
  products: Product[] | null;
  productsNodeIds: ProductNodeIds[] | null;
  responseShape: 'cart';
}
  • For product pages, it returns:
{
  product: Product;
  productNodeIds: ProductNodeIds | null;
  responseShape: 'product';
}
The Product type includes the following fields:
type Product = {
    name: string | null;
    price: number | null;
    currencyCode: string | null;
    quantity: number | null;
    imageUrls: string[] | null;
    description: string | null;
    categoryId: string | null;
    categoryBreadcrumb: string | null;
    categoryVersion: string | null;
    brandName: string | null;
    gtin: string | null;
    mpn: string | null;
    sku: string | null;
    asin: string | null;
};
Sleek will only return products on pages that are classified as product or cart. To determine the page classification, you can use the classifyPage method. See the page classification guide for more information. What’s next: Now that you have enabled product extraction in your extension, you can check out the TypeDoc for specific event types and methods on the web extension SDK.

View TypeDoc

Browse the reference TypeDoc for the web extension SDK.