> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onsleek.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Product extraction

> Specific integration instructions to enable product extraction.

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.

<Warning>
  This document assumes that you have already integrated the Sleek SDK. If you haven't, please refer to the [SDK integration guide](/js-sdk-reference/introduction).
</Warning>

## Enable product extraction

After Sleek SDK is installed and setup, 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:

<CodeGroup>
  ```html IIFE (via <script>) theme={null}
  <script src="f.js"></script>
  <script src="sdk.iife.js"></script>
  <script>
    sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE");

    const products = await sleek.getSdk().extractProducts(); // Returns Promise<ExtractProductsResult>

    const productsWithCategory = await sleek.getSdk().extractProducts(
      {
        includeCategory: true
      }
    );
  </script>
  ```

  ```typescript CJS / ESM theme={null}
  import { initializeSdk, getSdk } from "@sleek/sdk";

  initializeSdk("YOUR_PUBLIC_API_KEY_HERE");

  const products = await getSdk().extractProducts(); // Returns Promise<ExtractProductsResult>

  const productsWithCategory = await getSdk().extractProducts(
      {
        includeCategory: true
      }
    );
  ```
</CodeGroup>

The `extractProducts` method returns an object based on the type of page:

* For `cart` pages, it returns:

```typescript theme={null}
{
  products: Product[] | null;
  productsNodeIds: ProductNodeIds[] | null;
  responseShape: 'cart';
}
```

* For `product` pages, it returns:

```typescript theme={null}
{
  product: Product;
  productNodeIds: ProductNodeIds | null;
  responseShape: 'product';
}
```

The `Product` type includes the following fields:

```typescript theme={null}
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](/js-sdk-reference/page-classification) for more information.

**What's next:**

Now that you have enabled product extraction, you can check
out the TypeDoc for specific event types and methods on the SDK.

<Card title="View TypeDoc" icon="terminal" href="/js-sdk-reference/type-doc">
  Browse the reference TypeDoc for the SDK.
</Card>
