Skip to content

Recoms using REST API

The REST API can be used to load product recommendations.

Request

The endpoint is available at https://core.helloretail.com/serve/recoms. You use it by sending a HTTP POST request with a JSON body. The content type must be application/json or text/plain 1.

The JSON body must consist of an object with some overall properties. Inside this object is a list of requests for actual product recommendations.

Example of the structure the JSON body must have when loading:

{
    "websiteUuid":"4bb65cc4-f2d2-4eb0-80d9-9496f912d2cf",
    "trackingUserId":"62a0317d17698aa57d369db9",
    "requests":[
        request objects...
    ]
}

More information about each part of the JSON body

Name Type Description
websiteUuid String (optional for managed recoms) The id identifying the website in Hello Retail. This can be found on my.helloretail.com. This is only required if any of the requests are for unmanaged recoms. Read more about managed and unmanged recoms below
trackingUserId String (optional) Tracking user id that has been generated by Hello Retail. You can read more about the tracking user here. The id is only required when requesting recoms with algorithms that require a tracking user as input
requests RecomRequest[] A list of requests for product recommendations. Each request will be processed, and the response will contain a list of responses in the same order as the given requests. Products will not be repeated within the responses to one API call

The RecomRequest object has two different variants. One for managed product recommendations and one for unmanaged. You can read more about this distinction here.

Managed RecomRequest

Example of the structure of a RecomRequest for managed product recommendations:

 {
    "key": "k6449296dbbc4cd233cac2276",
    "format":"json",
    "fields": ["title", "url"],
    "context": {
        "hierarchies":[["Clothing","Women"]],
        "brand": "Nike",
        "urls": ["https://mywebshop.com/"]
    }
}

More information about each part of the managed RecomRequest

Name Type Description
format html json
fields String[] The list of fields to include for each product. This property is only used if the format is json
key String The product box key that identifies the configuration on My Hello Retail
context Object A key-value list providing the context used by the product sources configured on My Hello Retail. Any urls or productNumbers given here will be used to identify products to use as input to find related products, bought together and similar. Any other properties will be passed to the filters and source conditions in the algorithm.

Unmanaged RecomRequest

Example of the structure of a RecomRequest for unmanaged product recommendations:

{
    "trackingKey":"frontpage-1",
    "fields":["title","url"],
    "hideAdditionalVariants":true,
    "count":8,
    "context":{
        "urls": ["https://mywebshop.com/"]
    },
    "sources":[
        {
            "type":"RETARGETED",
            "limit": 2
        },
        {
            "type":"TOP",
            "filters":{
                "hierarchies":{"$in":[["Clothing", "Woman"]]}
            }
        }
    ]
}

More information about each part of the unmanaged RecomRequest

Name Type Description
trackingKey String that matches [0-9a-zA-Z-]{,100} A user defined string that is used to identify this product recommendation in the Hello Retail tracking system.
fields String[] The list of fields to include for each product
hideAdditionalVariants Boolean Boolean indicating if products with the same grouping key as a previous product should be excluded. The default is true
count Integer (greater than zero) Number of products to return (if they exist)
context Object A key-value list providing the context used by the sources configured on My Hello Retail. Any urls or productNumbers given here will be used to identify products to use as input to find related products, bought together and similar
sources ProductSource[] List of product sources as defined below

More information about each part of a ProductSource

Name Type Description
type String A string that identifies one of the available product source types. See the available options below
limit Integer (optional) The number of products to return from this source. This allows a single source to stop delivering products and let the next source take over
filters Object An object representing filters that will be applied to the products in the product source. See more below

Product Source Types

Type Description and input requirements
TOP The most popular products in the shop
MOST_BOUGHT The most bought products in the shop
MOST_VIEWED The most viewed products in the shop
ALTERNATIVES Alternative products to the products given in the context. Requires that either productNumbers or urls be provided in the context for the request
BOUGHT_TOGETHER Up-sell products to the products given in the context. Requires that either productNumbers or urls be provided in the context for the request
RETARGETED The products the visitor as viewed most recently. Requires that the trackingUserId is set in the request
RECENTLY_BOUGHT The products the visitor as bought most recently. Requires that the trackingUserId is set in the request

Filters

The filters object can contain a set of filters that will be applied to the products found by the product sources. Only the products that match all filters will be returned. Each filter consists of the name of the field to filter on and, an operator to use for filtering and a filter value.

The available filters are

Filter Description
$eq The field in the product must have the same value as the filter value
$in The field in the product must contain at least one of the values in the filter value. The filter value must be a list
$all The field in the product must contain all of the values in the filter value. The filter value must be a list

$eq is the default operator and will be used if the filter is just "key": "value":

Example

{
    "hierarchies":{"$all":[["Clothing", "Men"], ["Clothing", "Children"]]},
    "brand": {"$in": ["Nike", "Adidas"]},
    "extraData.size": "L"
}

Response

The response from both managed and unmanaged requests is an object containing a list of responses. The order of the responses is identical to the order of requests. The object also contains a boolean indicating if the request as a whole was received and processed. Each individual request can fail seperately, so check the status of the individual requests.

Example of a response to a request with a mix of request configurations

{
    "success": true,
    "responses": [
        {
            "key": "k6449296dbbc4cd233cac2276",
            "success": true,
            "products": [
                {"title": "Red shoe", "url": "https://shop.example.com/p-1"},
                {"title": "Blue shoe", "url": "https://shop.example.com/p-2"}
            ]
        },
        {
            "trackingKey": "frontpage-1",
            "success": true,
            "products": [
                {"title": "White hat", "url": "https://shop.example.com/p-3"},
                {"title": "Black hat", "url": "https://shop.example.com/p-4"}
            ]
        }
        {
            "key": "k6449296dbbc4cd233cac2276",
            "success": true,
            "html": "<a href='https://shop.example.com/p-3'>White hat</a><br><a href='https://shop.example.com/p-4'>Black hat</a>"
        },
        {
            "key": "k6449296dbbc4cd233cac2273",
            "success": false,
            "code": "NOT FOUND",
            "message": "Recom not found"
        }
    ]
}

More information about the response object

Name Type Description
success Boolean A boolean indicating if the request has succeeded. This will still be true even if all inner requests has failed. This only indicates if the request was received and processed
responses RecomResponse[] The list responses corresponding to the requests

More information about the RecomResponse object

Name Type Description
key String Key of the requested managed product recommendation. Will not be there if the reponse is to a request for unmanaged product recommendations
trackingKey String Tracking Key of the requested unmanaged product recommendation. Will not be there if the reponse is to a request for managed product recommendations
products Product[] A list of recommended products. Will only be here if the requested format is json
html String The product recommendations rendered as HTML using the liquid template in My Hello Retail. This will only be here for managed product recommendations where the requested format is html
code String Error code identifying. Only available if the request has failed (success=false)
message String Further information about the error. Only available if the request has failed (success=false)

  1. The reason for supporting text/plain is to allow requests to this endpoint, made from the browser, to be categorized as simple thereby avoiding CORS preflight requests. You can read more here https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests