Sleek’s 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 SDK into your extension. If you haven’t, please refer to the SDK integration guide.

Enable product extraction

After Sleek 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 either the extractProductsOnTab method for basic product information or extractExtendedProductsOnTab for more detailed product data.

The extractProductsOnTab method is faster and returns a more basic product object. The extractExtendedProductsOnTab method is slower and returns a more detailed product object.

Each method returns a promise that resolves to an array of products, one product, or undefined if no products are found. To type the return value, you can check if the return value is an array or a single product.

import { getSdkInstance } from "@sleek/web-ext-coupon-sdk";

getSdkInstance().extractProductsOnTab(tabId); // Returns Promise<CartProduct[] | ProductDetailProduct | undefined>.
const productResult = await getSdkInstance().extractExtendedProductsOnTab(tabId); // Returns Promise<ExtendedCartProduct[] | ExtendedProductDetailProduct | undefined>.

if (Array.isArray(productResult)) {
  // productResult is an array of products (ExtendedCartProduct[])
} else {
  // productResult is a single product (ExtendedProductDetailProduct)
}

Sleek will only return products on pages that are classified as productDetailPage or cart. To determine the page classification, you can use the classifyPageOnTab method. See the page classification guide for more information.

If the tab is a productDetailPage, calls to the extraction methods will return either ProductDetailProduct or ExtendedProductDetailProduct.

If the tab is a cart, calls to the extraction methods will return either CartProduct or ExtendedCartProduct.


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 SDK.

View TypeDoc

Browse the reference TypeDoc for the SDK.