Skip to content

POST /feedback

To make our search and browse services self learning, we collect feedback provided by the visitor. Feedback signals are implicit votes of approval of a visitor for an item. Examples of such feedback signals are clicks on an item, the addition of an item to the visitor's shopping basket, or the purchase of an item. These feedback signals are collected via our feedback API endpoint.

Request

HTTP request

POST https://api.904labs.com/sls/{customer_id}/feedback/{search_id}?api_key={api_key}

Request attributes

Attribute Type Description
customer_id string (required) Your customer ID
search_id string (required) Unique identifier of the session, provided by POST /search or POST /browse.

Request parameters

Parameter Type Description
api_key string (required) Your API key

Request body

The body of the request expects a JSON dictionary consisting of document_ids as keys with a feedback_value as value for each document that the user interacted with. This list indicates which documents from the ranked_list (from /search or /browse) received positive feedback, as well as the type of feedback.

We support three generic value levels for feedback and several specific types within these levels; high feedback level: PURCHASE; medium feedback level: ADD_TO_BASKET, STAR, LIKE; and low feedback level: VIEW, CLICK. In case the web app does not support multiple signals, CLICK is recommended as default.

Example request

import requests as r

headers = {"content-type": "application/json"}
URL_SEARCH = "https://api.904labs.com/sls/CUSTOMER_ID/feedback/SEARCH_ID"
params = {
    "api_key": "APIKEY"
}
payload = {
    "document_id_456": "PURCHASE",
    "document_id_148": "LIKE",
    "document_id_230": "CLICK"
}

response = r.post(URL_SEARCH, headers=headers, params=params, json=payload)

Response

{
  "success": true
}

Response HTTP codes

The endpoint returns an HTTP 200 (OK) status when feedback is processed successfully. If the search_id has expired (i.e., more than 10 minutes have passed between the search / browse action and feedback) or when it does not exist, the endpoint returns a 410 (Gone) error. In case the search_id is missing from the request, a 404 (Not Found) error is returned. When the request body is malformed (e.g., no document_ids in the body), a 400 (Bad Request) is returned. Finally, in case a bogus / non-existing document_id is submitted, feedback for this document is simply ignored, and a regular 200 (OK) is returned.