Techdocs
Search…
Querying Recommendations
You can generic recommendations using the GraphQL orders endpoint. The recommendations offered here don't use sessions so they aren't personalized but still offer enough flexibility to support a multitude of use-cases.

Fetching toplists recommendations

The endpoint can be used to fetch toplist recommendations i.e. best-sellers. Toplists recommendations are either sorted by views or buys.
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
toplist(hours: 168, sort: BUYS, params: {
8
minProducts: 1
9
maxProducts: 10
10
}) {
11
primary {
12
name
13
productId
14
}
15
}
16
}
17
}
18
EOF
Copied!

Fetching random recommendations

The endpoint can be used to fetch random recommendations i.e. previews. Random recommendations are a totally randomized selection of products and often used for testing purposes.
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
random(params: {
8
minProducts: 1
9
maxProducts: 10
10
}) {
11
primary {
12
name
13
productId
14
}
15
}
16
}
17
}
18
EOF
Copied!

Fetching related recommendations

The endpoint can be used to fetch related recommendations i.e. cross-sellers. Cross-sell recommendations allow you fetch related products to a given set of products.
Example: If you were to use this to add recommendations to a product page, the productIds parameter would be a single-item array containing the product identifiers of the product that is being viewed.
Example: If you were to use this to add recommendations to an order-follow email, the productIds parameter would be an array containing the product identifiers of the products that were purchased.
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
related(relationship: VIEWED_TOGETHER, productIds: [
8
"8685560646"
9
],
10
params: {
11
minProducts: 1
12
maxProducts: 10
13
}) {
14
primary {
15
name
16
productId
17
}
18
}
19
}
20
}
21
EOF
Copied!

Fetching search recommendations

The endpoint can be used to fetch recommendations related to a search term.
Example: If you were to use this to add recommendations to a search page, the term parameter would be the entire search term as queries by the user.
Note: This endpoint cannot be used for building auto-complete style integrations.
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
search(term: "shoes",
8
params: {
9
minProducts: 1
10
maxProducts: 10
11
}) {
12
primary {
13
name
14
productId
15
}
16
}
17
}
18
}
19
EOF
Copied!

Add inclusive or exclusive filters

In case some cases it is desired to filter products by their properties. include and exclude fields of primary should be used to achieve this. The former will filter only the products that match the specified attribute, the later will filter out the products that match the attribute.
include field expects a type of InputIncludeParams, whose attributes are
1
brands: [String]
2
The list of brand used for inclusion or exclusion
3
4
categories: [String]
5
The list of categories used for inclusion or exclusion
6
7
customFields: [InputAttributeParams]
8
The map of product attributes used for inclusion or exclusion
9
10
discounted: Boolean
11
A boolean indicating whether discounted products should be excluded
12
13
fresh: Boolean
14
A boolean value denoting the inclusion of new products
15
16
price: InputPriceParams
17
The price range used for inclusion
18
19
productIds: [String]
20
The list of product identifiers used for inclusion or exclusion
21
22
rating: Float
23
The minimum rating score for the inclusion
24
25
reviews: Int
26
The minimum amount of reviews for the inclusion
27
28
search: String
29
Search all products containing this text
30
31
stock: InputStockParams
32
The stock level range used for inclusion
33
34
tags1: [String]
35
The first set of tags used for inclusion or exclusion
36
37
tags2: [String]
38
The second set of tags used for inclusion or exclusion
39
40
tags3: [String]
41
The third set of tags used for inclusion or exclusion
Copied!
exclude field expect type InputFilterParams whose attributes are:
1
brands: [String]
2
The list of brand used for inclusion or exclusion
3
4
categories: [String]
5
The list of categories used for inclusion or exclusion
6
7
customFields: [InputAttributeParams]
8
The map of product attributes used for inclusion or exclusion
9
10
discounted: Boolean
11
A boolean indicating whether discounted products should be excluded
12
13
productIds: [String]
14
The list of product identifiers used for inclusion or exclusion
15
16
search: String
17
Search all products containing this text
18
19
tags1: [String]
20
The first set of tags used for inclusion or exclusion
21
22
tags2: [String]
23
The second set of tags used for inclusion or exclusion
24
25
tags3: [String]
26
The third set of tags used for inclusion or exclusion
Copied!
Here is an example of a query including filters
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
toplist(hours: 168, sort: BUYS, params: {
8
minProducts: 1
9
maxProducts: 10
10
includeFilters: {
11
customFields: [
12
{
13
"attribute": "pattern"
14
"values": "Solid"
15
}
16
]
17
discounted: true
18
}
19
}) {
20
primary {
21
name
22
productId
23
}
24
}
25
}
26
}
27
EOF
Copied!
Last modified 28d ago