User to Attributes API
The User to Attributes API is a generalized version of User to Categories API --- it returns the product
attributes that Miso expects to drive a conversion for the current
user. You specify a field in your Product catalog you want recommendations for, for example the brand or a custom field like
custom_attributes.director, and this API will return a list of values from that fields Miso expects users will be most
interested in, as well as a list of personalized product suggestions.
Applicable scenarios
This API is usually used in homepage recommendations, where users can interact with recommended attributes. For example, this API generates suggestions such as "brands you can like" or "creators you can like".
Basic usage
For basic usage of this API, you just need to let Miso knows the user_id or anonymous_id, and the field you
want to get recommendations for. For example, the following request will return the recommended director for
the given users:
POST https://api.askmiso.com/v1/recommendation/user_to_attributes
{
"user_id": "test",
"field": "custom_attributes.director",
"rows": 3,
"products_per_attribute": 2,
"fl": ["title"]
}
- field: the name of the field you want to get recommendation for
- rows: the number of categories to return
- products_per_attribute: the number of Products to return per each attribute
- fl: like in other Miso API, you can use
flto control which fields to return for each Product
The response of this request will be like:
{
"message": "success",
"data": {
"took": 296,
"miso_id": "9d7c8d9c-dd73-11eb-b20d-9a566192e5c6",
"attributes": [
{
"value": "Christopher Nolan",
"total": 12,
"recommended_products": [
{
"product_id": "tmdb-272",
"title": "Batman Begins (2005)"
},
{
"product_id": "tmdb-77",
"title": "Memento (2000)"
}
]
},
{
"value": "Ridley Scott",
"total": 26,
"recommended_products": [
{
"product_id": "tmdb-286217",
"title": "The Martian (2015)"
},
{
"product_id": "tmdb-4982",
"title": "American Gangster (2007)"
}
]
},
{
"value": "Quentin Tarantino",
"total": 13,
"recommended_products": [
{
"product_id": "tmdb-680",
"title": "Pulp Fiction (1994)"
},
{
"product_id": "tmdb-68718",
"title": "Django Unchained (2012)"
}
]
}
]
}
}
- attributes: a list of attributes recommended to the users.
- attributes[ ].value: the recommended attribute value (in this case, director name)
- attributes[ ].total: the total number of Products that have this attribute
- attributes[ ].recommended_products: a list of Products (with the attribute) recommended to the users
User to attributes recommendations. Given a user, recommend product attributes the user will be interested in as well as products in those attributes
- Type: string · Fieldfieldrequired
The attribute you want to make recommendations for. For example, the following query will recommend values from the
brandfield that Miso thinks the user will be interested in:{"field": "brand"}This API also works for custom attributes you define. For example, if you provide a
designercustom attribute, then, you can makedesignerrecommendations with the following query.{"field": "custom_attributes.designer"} - Type: array · Additional Interactionsadditional
_interactions A list of additional interaction records. You can use this fields to simulate user interactions without actually writing them to the interaction dataset.
- Type: string · Anonymous Idanonymous
_id The anonymous visitor who made the query and for whom Miso will personalize the results. Either
user_idoranonymous_idneeds to be specified for personalization to work. - Type: array string[] · Boost Attributesboost
_attributes The attributes to boost to the top of the recommendations
- Type: string · Boost Fqboost
_fq Defines a query in Elasticsearch query-string syntax (Lucene) that can be used to boost a subset of products to the top of the ranking, or to specific boost positions (See
boost_positionsparameter below.) For example, the query below will promote all the relevant products whose brand isNiketo the top of recommendation list:{ "boost_fq": "brand:\"Nike\"" }For a slightly more complex example, the query below will promote the Nike products which have also been tagged as
ON SALEto the top of the ranking:{ "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"" }It is worth mentioning that, Miso will only boost products that are relevant and have high likelihood to convert, and will not boost a low performance product only because it matches the boosting query.
Depending on your boosting rules, in certain cases, you would like to prevent recommendation results from being too monotone due to boosting. With Miso, you have two tools to do so.
First, you can specify
boost_positionsto place promoted products at specific positions in the ranking. For example, the query below will place boosted products only at the first and fourth places in the ranking (positions are 0-based), and place the remaining products in their original ranking, skipping these two positions.{ "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"", "boost_positions": [0, 3] }The second tool is
diversification.diversificationparameter, on a best-effort basis, will try to maintain a minimum distance between products that have the same attributes. For example, the following query will place products made by the same brand apart from each other.{ "boost_fq": "brand:\"Nike\" AND tags:\"ON SALE\"", "diversification": { "brand": {"minimum_distance": 1} } } - Type: array integer[] · Boost Positionsboost
_positions Defines a list of 0-based positions you want to place the boosted products at.
For example, the query below will promote products whose brand is
Nikeas the top and second recommendations:{ "boost_fq": "brand:\"Nike\"", "boost_positions": [0, 1] }If
boost_positionsis not specified (which is the default behavior), all the boosted products will be ranked higher than the rest of the products. - Type: string · Boost Rule Nameboost
_rule _name Name of the boosting rule. Use this to identify a boosting rule in _boosted_rules in the response
- Type: array object[] · Boost Rulesboost
_rules Define a list of boosting rules that will be applied to the search or recommendation results simultaneously.
boost_rulesparameter is particularly useful when you want to boost more than one sets of products, and promote each of them to different positions. For example, the query below will promote products whose brand isNiketo the top and second results, and products whose brand isAdidasto the third and fourth results:{ "boost_rules": [ { "boost_fq": "brand:\"Nike\"", "boost_positions": [0, 1] }, { "boost_fq": "brand:\"Adidas\"", "boost_positions": [2, 3] } ] } - Type: array string[] · Boosting Tags
When
boosting_tagsis given, and there are pre-defined boost rules have the same tag(s), those boost rules will be matched, regardless if the criteria is met or not.Useful when want to force trigger specific boost campaign.
- Type: object · Custom Contextcustom
_context Dictionary of custom context variables for the current browsing session. You can specify context variables specific to your websites or apps in a
{"KEY":VALUE}format, whereKEYmust be a string, andVALUEcan be:- a
bool - a
stringor anarray of string - a
numberor anarray of numbers - an
array of objects null
In certain cases, Miso will take these variables into account when generating results.
- a
- Type: boolean · Dedupe Product Group Iddedupe
_product _group _id Whether to dedupe product based on
product_group_id. Ifdedupe_product_group_id=true, Miso will prevent products with the sameproduct_group_idfrom showing multiple times in the search or recommendation results.This is particular useful when one product has multiple variants (for example, different sizes, colors, or materials), and you only want to show this product only once in the search or recommendation results. Miso will then return the variant that is most likely to be of the user's interest.
- Type: string · Engine Idengine
_id The engine you want to get results from. When you have more than one engine, you can use this parameter to specify the specific engine you want to get results from. If not specified, the default engine will be used.
- application/json
- application/json
curl 'https://api.askmiso.com/v1/recommendation/user_to_attributes?api_key=YOUR_SECRET_TOKEN' \
--request POST \
--header 'Content-Type: application/json' \
--data '{
"boosting_tags": [
"tag-1",
"quetag-2"
],
"field": "",
"boost_attributes": [],
"exclude_attributes": [],
"rows": 5,
"products_per_attribute": 2,
"engine_id": "",
"user_id": "",
"anonymous_id": "",
"user_hash": "",
"user_cohort": {
"additionalProperty": true
},
"type": "",
"dedupe_product_group_id": true,
"additional_interactions": [],
"fl": [],
"exclude": [
""
],
"custom_context": {
"session_variable_1": [
"value_1",
"value_2"
]
},
"fq": "",
"boost_fq": "",
"boost_positions": [
1
],
"boost_rule_name": "",
"boost_rules": [],
"geo": {
"filter": [],
"boost": []
}
}'
{
"message": "success",
"data": {
"took": 0,
"miso_id": "123e4567-e89b-12d3-a456-426614174000",
"attributes": [
{
"value": "Miso T-Shirt Shop",
"total": 1000,
"recommended_products": 1000
}
]
}
}