Contextualize REST API: User Context

Method description

Returns the top product attributes and the last visited specific products for a specific user and session. While the "userPreferences" and "sessionPreferences" are query agnostic, both "userLastViewedProducts" and "sessionLastViewedProducts" are returned for the specific query requested.

The product attribute preferences are calculated based on user clicks, add-to-carts and purchases and the values are normalized using a linear function.

Both "userPreferences" and "sessionPreferences" objects don't have a fixed order and it may change in between requests. Although, values for each preference are sorted by "weight" in descending order.

"userLastViewedProducts" and "sessionLastViewedProducts" weight is calculated using the different between the last time there was an interaction with the product and "now". So, the more recent events will have more weight than others that happened long ago. 

Remember that your EB Contextualize configuration could use different fields for the preferences calculations, so the ones showing below ("brand" and "gender") are just examples.

HTTP method

GET

URL schema

/v2/usercontext/all/{client_id}?user={user_id}&session={session_id}&query={query}&preferences.rows={preferences.rows}&last_products.rows={last_products.rows}&session.preferences.rows={session.preferences.rows}&session.last_products.rows={session.last_products.rows}

URL example

/v2/usercontext/all/ebdemo?user=user_test&session=session_test&query=dress&preferences.rows=5&last_products.rows=5&session.preferences.rows=5&session.last_products.rows=5

Path Parameters

Parameter nameRequiredDescription
client_id(tick)Client identifier on the system

URI Parameters

Parameter nameRequiredDescriptionDefault
user(tick)Identifier that represents an unique user along the client
session (error) 

Identifier that represents an unique session for the given user along the client

If it's not specified there isn't session object in response


query

(tick)

Search term that user did
preferences.rows(error) Number of user values of each field1
last_products.rows(error) Number of user products to return5
session.preferences.rows(error) Number of session values of each field1
session.last_products.rows(error) Number of session products to return5

Responses

200 - successful request

Type: application/json

Example application/json
{
  "userPreferences": [
    {
      "field": "brand",
      "values": [
        {"value": "apple", "weight": 3},
        {"value": "sony", "weight": 2.1}
      ]
    },
    {
      "field": "gender",
      "values": [
        {"value": "woman", "weight": 3}
      ]
    }
  ],
  "sessionPreferences": [
    {
      "field": "brand",
      "values": [
        {"value": "apple", "weight": 3}
      ]
    },
    {
      "field": "gender",
      "values": [
        {"value": "woman", "weight": 3}
      ]
    }
  ],
  "userLastViewedProducts": [
    {"value":"213115", weight:3},
    {"value":"213149", weight:1.3}
  ],
  "sessionLastViewedProducts": [
    {"value":"213142", weight:3}
  ]
}
400 - mandatory query parameter is missing

Type: application/json

Example application/json
{
  "code": 400,
  "error": "XXX is mandatory"
}
404 - either client or endpoint don't exist

Type: application/json

Example application/json
{
  "code": 404,
  "error": "XXX not found"
}