Skip to main content

Visual Discovery

This document explains the primary methods of the Visual Discovery, their use cases, inputs, and outputs.

1. visualSearch

The visualSearch method enables visual product discovery by allowing users to upload an image. The SDK analyzes the image to find visually similar products and provides optional bounding box data.

Use Case

  • Ideal for e-commerce platforms where customers want to search for products by uploading images (e.g., fashion, furniture, etc.).
  • Enables interaction with specific objects detected in the image through bounding boxes.

Inputs

OptionTypeDescription
fileDataFileThe image file uploaded by the user.
callbackFunctionFunction invoked when the search completes.

Outputs

The callback receives an object with:

PropertyTypeDescription
actionstringThe type of action performed (e.g., ImageSearch).
payloadObjectThe search results, including product items and bounding box data.

Note: Bounding Box Integration If bounding boxes (bbox) are included in the payload, you must implement a renderDotsAndBoxes method to display the dots and bounding boxes on the preview image. This method should dynamically render the detected areas and allow for interactivity.

For detailed guidance, please refer to:

  1. The Sample.
  2. The Bounding Boxes Interfaces and Example.

Example

window.FastSimonSDK.visualSearch({
fileData: file, // File object from an input field
callback: ({ action, payload }) => {
if (action === "ImageSearch" && payload.bbox) {
// Render dots and bounding boxes dynamically
renderDotsAndBoxes(payload.bbox);
}
if (action === "ImageSearch" && payload.items) {
const items = action === "ImageSearch" ? payload.items : [];
renderList("Search Results", items, false);
}
}
});

2. discoveryImages

The discoveryImages method retrieves a gallery of popular or curated images for visual discovery.

Use Case

  • Useful for showing trending or popular products to inspire customer purchases.

Inputs

OptionTypeDescription
modestringThe discovery mode (e.g., "popular").
callbackFunctionFunction invoked when the gallery retrieval completes.

Outputs

The callback receives an object with:

PropertyTypeDescription
actionstringThe type of action performed (e.g., DiscoveryImages).
payloadObjectThe gallery of images retrieved.

DiscoveryImage Interface Documentation

The DiscoveryImage interface represents the structure of images retrieved for discovery purposes, such as popular or trending products. The response payload for the discoveryImages method is an array of DiscoveryImage objects.

DiscoveryImages Response

The discoveryImages method returns a payload that is an array of DiscoveryImage objects:

Property Descriptions

PropertyTypeDescription
image_idstringUnique identifier for the image.
likesnumberPopularity score or number of likes for the image.
tstringTitle or main label of the image.
dstringDescription or additional context about the image.

Example

window.FastSimonSDK.discoveryImages({
mode: "popular",
callback: ({ action, payload }) => {
if (action === "DiscoveryImages") {
console.log("Gallery images:", payload);
}
}
});

3. productsByDiscovery

The productsByDiscovery method retrieves products based on a specific discovery mode, such as custom recommendations or related products.

Use Case

  • Useful for showing related products, cross-sell opportunities, or custom product recommendations.

Inputs

OptionTypeDescription
modestringThe discovery mode (e.g., "custom").
imageIDstring (Optional)ID of the reference image (if applicable).
callbackFunctionFunction invoked when discovery completes.

Outputs

The callback receives an object with:

PropertyTypeDescription
actionstringThe type of action performed (e.g., ProductsDiscovery).
payloadObjectThe discovery results, including product items.

Example

window.FastSimonSDK.productsByDiscovery({
mode: "custom",
imageID: "example-image-id",
callback: ({ action, payload }) => {
if (action === "ProductsDiscovery" && payload.items) {
console.log("Recommended products:", payload.items);
}
}
});

FetchProductsResponse Interface Documentation

The FetchProductsResponse interface represents the response structure returned when fetching products related to an uploaded image or a specific product.

Property Descriptions

PropertyTypeDescription
image_idstringUnique identifier for the uploaded or referenced image.
itemsProduct[]Array of products related to the query or image.
likesnumberPopularity score or number of likes for the result.
tstringTitle or main label for the result.
dstringDescription of the result or product group.
bboxApiBoundingBox[] (Optional)Bounding boxes around objects detected in the image.
complete_the_look{ [key: string]: Product[] } (Optional)Suggested products to "complete the look."
product_labelstring (Optional)Label or categorization for the result.
similarProduct[] (Optional)Array of products similar to the main result.
video_urlstring (Optional)URL to a related video showcasing the product or result.