Pages

Learn how to make a Smart Discovery API request to retrieve the data for a Smart Discovery:

For more information about Smart Discovery, see Feature: Smart Discovery.

Requests

URL

The URL for Smart Discovery API requests is https://<platform_instance>/recoApi/v2?method=smartDiscovery, where <platform_instance> is the domain name of your Frosmo Platform instance.

To get the URL for your Frosmo Platform instance:

  1. Log in to the Frosmo Control Panel, and select your site.
  2. In the header, click your username, and select API Access.
  3. In the Smart Discovery section, copy the URL.

    URL for Smart Discovery API requests

Authentication

The Smart Discovery API does not require authentication.

Methods

The Smart Discovery API supports the GET HTTP method for retrieving Smart Discovery data.

Syntax

To retrieve Smart Discovery data, make the following GET request:

GET https://<platform_instance>/recoApi/v2?method=smartDiscovery&
    origin=<site_origin>&
    pageType=<page_type>&
    context=<page_context>&
    cookieId=<local_frosmo_id>

Parameters

Table: Query parameters for Smart Discovery API requests

ParameterDescriptionTypeRoleExample
method

Request type.

Use the value smartDiscovery.

StringRequired
method=smartDiscovery
origin

Site origin.

To find out your site's origin, see Getting your site origin.

StringRequired
origin=shop_company_com
pageType

Type of the page for which to retrieve the Smart Discovery data.

The possible values are:

  • category: The API returns the Smart Discovery data for a category page. The specific category page must be defined in the context parameter.
  • home: The API returns the Smart Discovery data for the site home page.
StringRequired
pageType=home
context

Contextual information about the page where the API request is made.

The information allows the API to return the correct Smart Discovery data for the page. The exact information required depends on the page type.

The value is a JSON object containing a single page property: the page context object.

Object

See Page context object.

Required
# Home page context

context={
  "page": {
    "type": "home"
  }
}

# Category page context

context={
  "page": {
    "type": "category",
    "category": {
      "categories": [
        "Fashion/Shoes"
      ]
    }
  }
}
cookieId

Local Frosmo ID of the visitor who sees the Smart Discovery.

The platform uses the ID to sort the suggestions in the Smart Discovery data based on the visitor's affinities.

StringRequired
cookieId=dsr77t.kstzihlx
limit

Maximum number of suggestions to return in the Smart Discovery data. The API returns the top suggestions by relevance (as determined by item popularity and the visitor's affinities).

The minimum value is 1. There is no maximum value.

The default value is 20.

NumberOptional
limit=10
profile

Define the visitor's profiling choice if the site uses selective profiling. The choice determines whether the API returns Smart Discovery data that is personalized for the visitor.

The possible values are:

  • opt-in: The visitor has opted in to seeing personalized, targeted content.
  • opt-out: The visitor has opted out of seeing personalized, targeted content.
  • Empty: The visitor has not made their profiling choice.

The default value is empty.

Each visitor's profiling choice is stored in their context. You can get the choice using the frosmo.easy.profile.get() function.

You must always define this parameter on a site that uses selective profiling.

Never define this parameter on a site that does not use selective profiling.

How the profiling choice works

If you set the value to opt-in or empty, the API returns the Smart Discovery data normally.

If you set the value to opt-out, the API returns the baseline Smart Discovery data, meaning the platform does not sort the suggestions in the data based on the visitor's affinities.

StringOptional
profile=opt-out
debug

Define whether to return debugging information about the request.

Use the debugging information only for development and testing purposes. Do not use the information in production, since Frosmo does not guarantee that the information structure and content will remain the same.

The debugging information consists of:

  • Affinity profile of the visitor specified by the cookieId parameter
  • Additional details about the request, such as issues that did not cause the request to fail but that may indicate a problem

The possible values are:

  • false: Do not return debugging information.
  • true: Return debugging information.

The default value is false.

BooleanOptional
debug=true

Page context object

The following table describes the page object of the context parameter value. The page object provides contextual information about the page where the API request is made.

Table: Page context object properties

PropertyDescriptionTypeRoleExample
type

Type of the page where the API request is made.

The possible values are:

  • category: The API request is made on a category page.
  • home: The API request is made on the site home page.

The value must match the pageType parameter value.

StringRequired
"type": "category"
category

Contextual information about the category page where the API request is made.

This property is required only if the type property is set to category.

Category page context objectRequired
"category": {
  "categories": [
    "Fashion/Shoes"
  ]
}

Category page context object

The following table describes the category object of the page context object. The category object provides contextual information about the category page where the API request is made.

Table: Category page context object properties

PropertyDescriptionTypeRoleExample
categories

Names of the categories whose items are shown on the category page where the API request is made.

Smart Discovery only uses the first name in the array. Make sure the first name is the category whose Smart Discovery data you want to retrieve.

Smart Discovery uses "starts with" partial matching to check the category name against category-based discoveries generated for the site. For example:

  • If the current category page is Fashion, the API returns all discoveries whose category name starts with "Fashion", such as Fashion, Fashion/Shoes, and Fashion/Shoes/Sneakers.
  • If the current category page is Fashion/Shoes, the API returns all discoveries whose category name starts with "Fashion/Shoes", such as Fashion/Shoes and Fashion/Shoes/Sneakers.

For more information about the returned data, see Responses.

Array of stringsRequired
"categories": [
  "Fashion/Shoes"
]

Request examples

Example: Retrieve selection data for the home page
GET https://inpref.com/recoApi/v2?method=smartDiscovery&
    origin=shop_company_com&
    pageType=home&
    context={
      "page": {
        "type": "home"
      }
    }&
    cookieId=dsr77t.kstzihlx
Example: Retrieve selection data for a category page
GET https://inpref.com/recoApi/v2?method=smartDiscovery&
    origin=shop_company_com&
    pageType=category&
    context={
      "page": {
        "type": "category",
        "category": {
          "categories": [
            "Fashion/Shoes"
          ]
        }
      }
    }&
    cookieId=dsr77t.kstzihlx
Example: Retrieve selection data for a category page with a custom suggestions limit
GET https://inpref.com/recoApi/v2?method=smartDiscovery&
    origin=shop_company_com&
    pageType=category&
    context={
      "page": {
        "type": "category",
        "category": {
          "categories": [
            "Fashion/Shoes"
          ]
        }
      }
    }&
    cookieId=dsr77t.kstzihlx&
    limit=10

Responses

Success

On a success, the Smart Discovery API returns the requested Smart Discovery data in a JSON object. The response status code is 200.

The response object contains the following root properties:

  • data: Array of objects with a single object containing the following properties:
    • pageType: Type of the page whose Smart Discovery data was returned.
    • attributeValue: Name of the category whose Smart Discovery data was returned. The name matches the category name passed in the category page context object. If pageType is home, the value is empty.
    • items: Smart Discovery data as an array of objects, where each object contains the details of a single Smart Discovery suggestion. The suggestions are in descending order of relevance (as determined by item popularity and the visitor's affinities). Use the details to build and render the individual suggestions in a Smart Discovery web page element.

      For categories:

      • If the category name passed in the category page context object matched a single discovery, the data contains the suggestions from that discovery.
      • If the category name passed in the category page context object matched multiple discoveries, the data contains the suggestions from all the discoveries ranked by weight and with duplicate suggestions removed.

      If two suggestions have the same image value, the API considers them duplicates and removes the suggestion with the lower weight (a measure of item popularity).

  • debug: Object containing the debugging information. This property is included only when the debug parameter is set to true in the request.
Response structure without debugging information
{
  "data": [{
    "pageType": "<page_type>",
    "attributeValue": "<category_name | empty>",
    "items": [
      {<suggestion 1 data>},
      {<suggestion 2 data>},
      ...
      {<suggestion n data>}
    ]
  }]
}
Response structure with debugging information
{
  "data": [{
    "pageType": "<page_type>",
    "attributeValue": "<category_name | empty>",
    "items": [
      {<suggestion 1 data>},
      {<suggestion 2 data>},
      ...
      {<suggestion n data>}
    ]
  }],
  "debug": {
    <debugging information>
  }
}

Success examples

The following two examples show the same response without and with debugging information.

Example: Response with selection data only
{
  "data": [
    {
      "pageType": "home",
      "attributeValue": "",
      "items": [
        {
          "query": "Wakita Drills",
          "title": "Wakita Drills",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-4.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Drills"
          },
          "weight": 59
        },
        {
          "query": "Wakita Woodworking",
          "title": "Wakita Woodworking",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-1.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Woodworking"
          },
          "weight": 57
        },
        {
          "query": "Wakita Saws",
          "title": "Wakita Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-2.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Saws"
          },
          "weight": 50
        },
        {
          "query": "Wakita Large Tools",
          "title": "Wakita Large Tools",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-6.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Large Tools"
          },
          "weight": 49
        },
        {
          "query": "Wakita Plumbing",
          "title": "Wakita Plumbing",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-8.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Plumbing"
          },
          "weight": 48
        },
        {
          "query": "Wakita Wrenches and Pliers",
          "title": "Wakita Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-5.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 42
        },
        {
          "query": "Sawyer Saws",
          "title": "Sawyer Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-3.jpg",
          "affinity": 1280,
          "facets": {
            "brand": "Sawyer",
            "subcategory": "Saws"
          },
          "weight": 40
        },
        {
          "query": "Cakita Drills",
          "title": "Cakita Drills",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-16.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Drills"
          },
          "weight": 37
        },
        {
          "query": "Cakita Woodworking",
          "title": "Cakita Woodworking",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-15.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Woodworking"
          },
          "weight": 35
        },
        {
          "query": "Cakita Compressors",
          "title": "Cakita Compressors",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-14.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Compressors"
          },
          "weight": 31
        },
        {
          "query": "Cakita Large Tools",
          "title": "Cakita Large Tools",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-13.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Large Tools"
          },
          "weight": 25
        },
        {
          "query": "Cakita Wrenches and Pliers",
          "title": "Cakita Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-9.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 23
        },
        {
          "query": "Cakita Kits",
          "title": "Cakita Kits",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-11.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Kits"
          },
          "weight": 19
        },
        {
          "query": "Cakita Chain Saws",
          "title": "Cakita Chain Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-12.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Chain Saws"
          },
          "weight": 14
        },
        {
          "query": "Cakita Plumbing",
          "title": "Cakita Plumbing",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-10.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Plumbing"
          },
          "weight": 9
        },
        {
          "query": "Wrenchy Wrenches and Pliers",
          "title": "Wrenchy Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-7.jpg",
          "affinity": 0,
          "facets": {
            "brand": "Wrenchy",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 5
        }
      ]
    }
  ]
}
Example: Response with selection data and debugging information
{
  "data": [
    {
      "pageType": "home",
      "attributeValue": "",
      "items": [
        {
          "query": "Wakita Drills",
          "title": "Wakita Drills",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-4.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Drills"
          },
          "weight": 59
        },
        {
          "query": "Wakita Woodworking",
          "title": "Wakita Woodworking",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-1.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Woodworking"
          },
          "weight": 57
        },
        {
          "query": "Wakita Saws",
          "title": "Wakita Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-2.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Saws"
          },
          "weight": 50
        },
        {
          "query": "Wakita Large Tools",
          "title": "Wakita Large Tools",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-6.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Large Tools"
          },
          "weight": 49
        },
        {
          "query": "Wakita Plumbing",
          "title": "Wakita Plumbing",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-8.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Plumbing"
          },
          "weight": 48
        },
        {
          "query": "Wakita Wrenches and Pliers",
          "title": "Wakita Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-5.jpg",
          "affinity": 6880,
          "facets": {
            "brand": "Wakita",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 42
        },
        {
          "query": "Sawyer Saws",
          "title": "Sawyer Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-3.jpg",
          "affinity": 1280,
          "facets": {
            "brand": "Sawyer",
            "subcategory": "Saws"
          },
          "weight": 40
        },
        {
          "query": "Cakita Drills",
          "title": "Cakita Drills",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-16.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Drills"
          },
          "weight": 37
        },
        {
          "query": "Cakita Woodworking",
          "title": "Cakita Woodworking",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-15.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Woodworking"
          },
          "weight": 35
        },
        {
          "query": "Cakita Compressors",
          "title": "Cakita Compressors",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-14.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Compressors"
          },
          "weight": 31
        },
        {
          "query": "Cakita Large Tools",
          "title": "Cakita Large Tools",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-13.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Large Tools"
          },
          "weight": 25
        },
        {
          "query": "Cakita Wrenches and Pliers",
          "title": "Cakita Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-9.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 23
        },
        {
          "query": "Cakita Kits",
          "title": "Cakita Kits",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-11.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Kits"
          },
          "weight": 19
        },
        {
          "query": "Cakita Chain Saws",
          "title": "Cakita Chain Saws",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-12.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Chain Saws"
          },
          "weight": 14
        },
        {
          "query": "Cakita Plumbing",
          "title": "Cakita Plumbing",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-10.jpg",
          "affinity": 480,
          "facets": {
            "brand": "Cakita",
            "subcategory": "Plumbing"
          },
          "weight": 9
        },
        {
          "query": "Wrenchy Wrenches and Pliers",
          "title": "Wrenchy Wrenches and Pliers",
          "image": "https://sales-retail-bp.docker-box.inpref.com/images/products/product-7.jpg",
          "affinity": 0,
          "facets": {
            "brand": "Wrenchy",
            "subcategory": "Wrenches and Pliers"
          },
          "weight": 5
        }
      ]
    }
  ],
  "debug": {
    "affinity": {
      "applied": true,
      "userScores": {
        "scores": {
          "brand": {
            "cakita": 480,
            "sawyer": 1280,
            "wakita": 6880
          },
          "category": {
            "other/plumbing": 480,
            "power tools/drills": 3200,
            "power tools/saws": 2560,
            "power tools/woodworking": 2400
          },
          "manufacturer": {
            "cakita": 480,
            "sawyer": 1280,
            "wakita": 6880
          },
          "type": {
            "other/plumbing": 480,
            "power tools/drills": 3200,
            "power tools/saws": 2560,
            "power tools/woodworking": 2400
          }
        },
        "created_at": "2023-06-12T14:52:48+02:00",
        "updated_at": "2023-06-12T20:19:26+02:00"
      },
      "details": [

      ]
    }
  }
}

Error

On an error, the Smart Discovery API returns the response status code 400 and an error message.

Table: Smart Discovery API error messages

Error messageDescriptionSolution
parameter 'method' missing
The method query parameter is missing from the request URL.Provide the method query parameter.
parameter 'method' contains an empty value
The value of the method query parameter is missing.Provide a non-empty value for the method query parameter.
parameter 'method' invalid
The value of the method query parameter is invalid.Provide smartDiscovery as the value of the method query parameter.
parameter 'origin' missing
The origin query parameter is missing from the request URL.Provide the origin query parameter.
parameter 'origin' contains an empty value
The value of the origin query parameter is missing.Provide a non-empty value for the origin query parameter.
parameter 'origin' invalid
The value of the origin query parameter is invalid.

Provide a valid site origin as the value of the origin query parameter.

To find out your site's origin, see Getting your site origin.

parameter 'pageType' invalid, expected either 'category' or 'home'
The pageType query parameter is missing from the request URL or the value of the parameter is invalid or missing.

Provide the pageType query parameter with one of the following values:

  • category
  • home
parameter 'context' invalid: missing category value
The context query parameter is missing from the request URL or the value of the categories property is missing.Provide the context query parameter, and make sure the categories property contains the name of a category.
parameter 'context' contains invalid JSON: failed to parse
The value of the context query parameter is not a valid JSON object.Provide a valid JSON object as the value of the context query parameter.
parameter 'cookieId' contains an empty value
The value of the cookieId query parameter is missing.Provide a non-empty value for the cookieId query parameter.