recombee-api-client 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -14
- package/lib/api-client.js +49 -37
- package/lib/errors/response-error.js +2 -2
- package/lib/requests/add-search-synonym.js +60 -0
- package/lib/requests/delete-all-search-synonyms.js +40 -0
- package/lib/requests/delete-item.js +1 -1
- package/lib/requests/delete-more-items.js +44 -0
- package/lib/requests/delete-search-synonym.js +42 -0
- package/lib/requests/delete-user.js +1 -1
- package/lib/requests/index.js +8 -3
- package/lib/requests/list-search-synonyms.js +55 -0
- package/lib/requests/recommend-items-to-item.js +9 -4
- package/lib/requests/recommend-items-to-user.js +10 -5
- package/lib/requests/recommend-next-items.js +55 -0
- package/lib/requests/recommend-users-to-item.js +4 -2
- package/lib/requests/recommend-users-to-user.js +5 -3
- package/lib/requests/search-items.js +8 -3
- package/lib/requests/update-more-items.js +53 -0
- package/package.json +2 -3
- package/test/add-bookmark-batch_test.js +11 -11
- package/test/add-bookmark-test.js +24 -12
- package/test/add-cart-addition-batch_test.js +11 -11
- package/test/add-cart-addition-test.js +24 -12
- package/test/add-detail-view-batch_test.js +11 -11
- package/test/add-detail-view-test.js +24 -12
- package/test/add-group-batch_test.js +8 -8
- package/test/add-group-callback_test.js +1 -1
- package/test/add-group-test.js +13 -7
- package/test/add-item-batch_test.js +8 -8
- package/test/add-item-callback_test.js +1 -1
- package/test/add-item-property-batch_test.js +8 -8
- package/test/add-item-property-test.js +12 -6
- package/test/add-item-test.js +13 -7
- package/test/add-purchase-batch_test.js +11 -11
- package/test/add-purchase-test.js +24 -12
- package/test/add-rating-batch_test.js +11 -11
- package/test/add-rating-test.js +30 -15
- package/test/add-search-synonym-batch_test.js +37 -0
- package/test/add-search-synonym-callback_test.js +47 -0
- package/test/add-search-synonym-test.js +45 -0
- package/test/add-series-batch_test.js +8 -8
- package/test/add-series-callback_test.js +1 -1
- package/test/add-series-test.js +13 -7
- package/test/add-user-batch_test.js +8 -8
- package/test/add-user-callback_test.js +1 -1
- package/test/add-user-property-batch_test.js +8 -8
- package/test/add-user-property-test.js +12 -6
- package/test/add-user-test.js +13 -7
- package/test/delete-all-search-synonyms-batch_test.js +33 -0
- package/test/delete-all-search-synonyms-callback_test.js +35 -0
- package/test/delete-all-search-synonyms-test.js +31 -0
- package/test/delete-bookmark-batch_test.js +5 -5
- package/test/delete-bookmark-test.js +6 -3
- package/test/delete-cart-addition-batch_test.js +5 -5
- package/test/delete-cart-addition-test.js +6 -3
- package/test/delete-detail-view-batch_test.js +5 -5
- package/test/delete-detail-view-test.js +6 -3
- package/test/delete-group-batch_test.js +8 -8
- package/test/delete-group-callback_test.js +1 -1
- package/test/delete-group-test.js +19 -10
- package/test/delete-item-batch_test.js +8 -8
- package/test/delete-item-callback_test.js +1 -1
- package/test/delete-item-property-batch_test.js +8 -8
- package/test/delete-item-property-callback_test.js +1 -1
- package/test/delete-item-property-test.js +19 -10
- package/test/delete-item-test.js +19 -10
- package/test/delete-more-items-batch_test.js +35 -0
- package/test/delete-more-items-callback_test.js +37 -0
- package/test/delete-more-items-test.js +33 -0
- package/test/delete-purchase-batch_test.js +5 -5
- package/test/delete-purchase-test.js +6 -3
- package/test/delete-rating-batch_test.js +5 -5
- package/test/delete-rating-test.js +6 -3
- package/test/delete-search-synonym-batch_test.js +42 -0
- package/test/delete-search-synonym-callback_test.js +53 -0
- package/test/delete-search-synonym-test.js +47 -0
- package/test/delete-series-batch_test.js +8 -8
- package/test/delete-series-callback_test.js +1 -1
- package/test/delete-series-test.js +19 -10
- package/test/delete-user-batch_test.js +8 -8
- package/test/delete-user-callback_test.js +1 -1
- package/test/delete-user-property-batch_test.js +8 -8
- package/test/delete-user-property-callback_test.js +1 -1
- package/test/delete-user-property-test.js +19 -10
- package/test/delete-user-test.js +19 -10
- package/test/delete-view-portion-batch_test.js +5 -5
- package/test/delete-view-portion-test.js +6 -3
- package/test/get-item-property-info-batch_test.js +7 -7
- package/test/get-item-values-batch_test.js +6 -6
- package/test/get-user-property-info-batch_test.js +7 -7
- package/test/get-user-values-batch_test.js +6 -6
- package/test/insert-to-group-batch_test.js +30 -20
- package/test/insert-to-group-test.js +6 -3
- package/test/insert-to-series-batch_test.js +30 -20
- package/test/insert-to-series-test.js +6 -3
- package/test/list-group-items-batch_test.js +7 -7
- package/test/list-groups-batch_test.js +5 -5
- package/test/list-item-bookmarks-batch_test.js +7 -7
- package/test/list-item-cart-additions-batch_test.js +7 -7
- package/test/list-item-detail-views-batch_test.js +7 -7
- package/test/list-item-properties-batch_test.js +5 -5
- package/test/list-item-purchases-batch_test.js +7 -7
- package/test/list-item-ratings-batch_test.js +7 -7
- package/test/list-item-view-portions-batch_test.js +7 -7
- package/test/list-items-batch_test.js +7 -7
- package/test/list-search-synonyms-batch_test.js +44 -0
- package/test/list-search-synonyms-callback_test.js +53 -0
- package/test/list-search-synonyms-test.js +41 -0
- package/test/list-series-batch_test.js +5 -5
- package/test/list-series-items-batch_test.js +7 -7
- package/test/list-user-bookmarks-batch_test.js +7 -7
- package/test/list-user-cart-additions-batch_test.js +7 -7
- package/test/list-user-detail-views-batch_test.js +7 -7
- package/test/list-user-properties-batch_test.js +5 -5
- package/test/list-user-purchases-batch_test.js +7 -7
- package/test/list-user-ratings-batch_test.js +7 -7
- package/test/list-user-view-portions-batch_test.js +7 -7
- package/test/list-users-batch_test.js +7 -7
- package/test/merge-users-batch_test.js +19 -14
- package/test/merge-users-test.js +6 -3
- package/test/recommend-items-to-item-batch_test.js +6 -6
- package/test/recommend-items-to-user-batch_test.js +6 -6
- package/test/recommend-next-items-batch_test.js +45 -0
- package/test/recommend-next-items-callback_test.js +54 -0
- package/test/recommend-next-items-test.js +42 -0
- package/test/recommend-users-to-item-batch_test.js +6 -6
- package/test/recommend-users-to-user-batch_test.js +6 -6
- package/test/remove-from-group-batch_test.js +5 -5
- package/test/remove-from-group-test.js +6 -3
- package/test/remove-from-series-batch_test.js +6 -6
- package/test/remove-from-series-test.js +12 -6
- package/test/search-items-batch_test.js +9 -9
- package/test/set-environment.js +6 -4
- package/test/set-item-values-batch_test.js +9 -9
- package/test/set-item-values-test.js +6 -3
- package/test/set-user-values-batch_test.js +9 -9
- package/test/set-user-values-test.js +6 -3
- package/test/set-view-portion-batch_test.js +10 -10
- package/test/set-view-portion-test.js +30 -15
- package/test/update-more-items-batch_test.js +35 -0
- package/test/update-more-items-callback_test.js +37 -0
- package/test/update-more-items-test.js +33 -0
- package/lib/requests/item-based-recommendation.js +0 -187
- package/lib/requests/user-based-recommendation.js +0 -168
- package/test/item-based-recommendation-batch_test.js +0 -41
- package/test/item-based-recommendation-callback_test.js +0 -65
- package/test/item-based-recommendation-test.js +0 -53
- package/test/user-based-recommendation-batch_test.js +0 -41
- package/test/user-based-recommendation-callback_test.js +0 -65
- package/test/user-based-recommendation-test.js +0 -53
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ client.send(new AddDetailView,
|
|
|
44
44
|
var recombee = require('recombee-api-client');
|
|
45
45
|
var rqs = recombee.requests;
|
|
46
46
|
|
|
47
|
-
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--');
|
|
47
|
+
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--', {region: 'us-west'});
|
|
48
48
|
|
|
49
49
|
// Prepare some userIDs and itemIDs
|
|
50
50
|
const NUM = 100;
|
|
@@ -71,17 +71,23 @@ userIds.forEach((userId) => {
|
|
|
71
71
|
|
|
72
72
|
// Send the data to Recombee, use Batch for faster processing of larger data
|
|
73
73
|
client.send(new rqs.Batch(purchases))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
.then(() => {
|
|
75
|
+
//Get 5 recommended items for user 'user-25'
|
|
76
|
+
return client.send(new rqs.RecommendItemsToUser('user-25', 5));
|
|
77
|
+
})
|
|
78
|
+
.then((response) => {
|
|
79
|
+
console.log("Recommended items for user-25: %j", response.recomms);
|
|
80
|
+
|
|
81
|
+
// User scrolled down - get next 3 recommended items
|
|
82
|
+
return client.send(new rqs.RecommendNextItems(response.recommId, 3));
|
|
83
|
+
})
|
|
84
|
+
.then((response) => {
|
|
85
|
+
console.log("Next recommended items for user-25: %j", response.recomms);
|
|
86
|
+
})
|
|
87
|
+
.catch((error) => {
|
|
88
|
+
console.error(error);
|
|
89
|
+
// Use fallback
|
|
90
|
+
});
|
|
85
91
|
```
|
|
86
92
|
|
|
87
93
|
### Using property values
|
|
@@ -90,7 +96,7 @@ client.send(new rqs.Batch(purchases))
|
|
|
90
96
|
var recombee = require('recombee-api-client');
|
|
91
97
|
var rqs = recombee.requests;
|
|
92
98
|
|
|
93
|
-
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--');
|
|
99
|
+
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--', {region: 'ap-se'});
|
|
94
100
|
const NUM = 100;
|
|
95
101
|
|
|
96
102
|
// We will use computers as items in this example
|
|
@@ -180,7 +186,7 @@ client.send(new rqs.Batch([
|
|
|
180
186
|
})
|
|
181
187
|
.then((recommended) => {
|
|
182
188
|
// Perform personalized full-text search with a user's search query (e.g. "computers")
|
|
183
|
-
return client.send(new rqs.SearchItems('user-42', 'computers', 5));
|
|
189
|
+
return client.send(new rqs.SearchItems('user-42', 'computers', 5, {'scenario': "search_top"}));
|
|
184
190
|
})
|
|
185
191
|
.then((matched) => {
|
|
186
192
|
console.log("Matched items: %j", matched)
|
package/lib/api-client.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const jsSHA = require("jssha");
|
|
4
|
-
const
|
|
5
|
-
const rp_errors = require('request-promise/errors');
|
|
4
|
+
const got = require('got');
|
|
6
5
|
|
|
7
6
|
const api_errors = require('./errors');
|
|
8
7
|
const requests = require('./requests');
|
|
@@ -17,15 +16,17 @@ class ApiClient {
|
|
|
17
16
|
* Construct the client
|
|
18
17
|
* @param {string} databaseId - ID of your database
|
|
19
18
|
* @param {string} secretToken - Corresponding secret token
|
|
20
|
-
* @param {boolean} alwaysUseHttps - If true, all requests are sent using HTTPS (default: true)
|
|
21
19
|
* @param {Object} options - Other custom options
|
|
22
20
|
*/
|
|
23
|
-
constructor (databaseId, token,
|
|
21
|
+
constructor (databaseId, token, options) {
|
|
24
22
|
this.databaseId = databaseId;
|
|
25
23
|
this.token = token;
|
|
26
|
-
this.alwaysUseHttps = (alwaysUseHttps === undefined) ? true : alwaysUseHttps;
|
|
27
24
|
this.options = options || {};
|
|
28
|
-
|
|
25
|
+
|
|
26
|
+
if (Object.getPrototypeOf(this.options) !== Object.prototype) throw new Error(`options must be given as an Object (${this.options} given instead)`);
|
|
27
|
+
|
|
28
|
+
this.protocol = this.options.protocol || 'https';
|
|
29
|
+
this.baseUri = this._getBaseUri()
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -41,50 +42,69 @@ class ApiClient {
|
|
|
41
42
|
let url = this._buildRequestUrl(request);
|
|
42
43
|
let options = {
|
|
43
44
|
method: request.method,
|
|
44
|
-
|
|
45
|
+
url: url,
|
|
45
46
|
headers: {'Accept': 'application/json',
|
|
46
47
|
'Content-Type': 'application/json',
|
|
47
|
-
'User-Agent': 'recombee-node-api-client/
|
|
48
|
-
timeout: request.timeout
|
|
49
|
-
resolveWithFullResponse: true,
|
|
50
|
-
json: true
|
|
48
|
+
'User-Agent': 'recombee-node-api-client/4.0.0'},
|
|
49
|
+
timeout: request.timeout
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
if (
|
|
54
|
-
options.
|
|
55
|
-
|
|
56
|
-
if (request.bodyParameters())
|
|
57
|
-
options.body = request.bodyParameters();
|
|
52
|
+
if (Object.entries(request.bodyParameters()).length > 0)
|
|
53
|
+
options.json = request.bodyParameters();
|
|
58
54
|
|
|
59
|
-
return
|
|
60
|
-
.
|
|
55
|
+
return got(options)
|
|
56
|
+
.json()
|
|
61
57
|
.then((response)=> {
|
|
62
58
|
return new Promise( (resolve) => {
|
|
63
59
|
if (callback) { return callback(null, response); }
|
|
64
60
|
return resolve(response);
|
|
65
61
|
});
|
|
66
62
|
})
|
|
67
|
-
.catch(
|
|
68
|
-
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
if (error instanceof got.HTTPError) {
|
|
65
|
+
error = new api_errors.ResponseError(request, error.response.statusCode, error.response.body);
|
|
69
66
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throw error;
|
|
67
|
+
else if (error instanceof got.RequestError) {
|
|
68
|
+
if(error.code === 'ETIMEDOUT' || error.code === 'ESOCKETTIMEDOUT') {
|
|
69
|
+
error = new api_errors.TimeoutError(request, error);
|
|
70
|
+
}
|
|
75
71
|
}
|
|
76
|
-
))
|
|
77
|
-
.catch((error) => {
|
|
78
72
|
if (callback) {return callback(error)};
|
|
79
73
|
throw error;
|
|
80
74
|
});
|
|
81
75
|
}
|
|
82
76
|
|
|
77
|
+
_getRegionalBaseUri(region) {
|
|
78
|
+
const uri = {
|
|
79
|
+
'ap-se': 'rapi-ap-se.recombee.com',
|
|
80
|
+
'ca-east': 'rapi-ca-east.recombee.com',
|
|
81
|
+
'eu-west': 'rapi-eu-west.recombee.com',
|
|
82
|
+
'us-west': 'rapi-us-west.recombee.com'
|
|
83
|
+
}[region.toLowerCase()];
|
|
84
|
+
|
|
85
|
+
if (uri === undefined) {
|
|
86
|
+
throw new Error(`Region "${region}" is unknown. You may need to update the version of the SDK.`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return uri;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_getBaseUri() {
|
|
93
|
+
let baseUri = process.env.RAPI_URI || this.options.baseUri;
|
|
94
|
+
if (this.options.region) {
|
|
95
|
+
if (baseUri) {
|
|
96
|
+
throw new Error('baseUri and region cannot be specified at the same time');
|
|
97
|
+
}
|
|
98
|
+
baseUri = this._getRegionalBaseUri(this.options.region);
|
|
99
|
+
}
|
|
100
|
+
return baseUri || 'rapi.recombee.com';
|
|
101
|
+
}
|
|
102
|
+
|
|
83
103
|
_buildRequestUrl(request) {
|
|
84
|
-
let
|
|
104
|
+
let usedProtocol = (request.ensureHttps) ? 'https' : this.protocol;
|
|
85
105
|
let reqUrl = request.path + this._encodeRequestQueryParams(request);
|
|
86
106
|
let signedUrl = this._signUrl(reqUrl);
|
|
87
|
-
return
|
|
107
|
+
return usedProtocol + '://' + this.baseUri + signedUrl;
|
|
88
108
|
}
|
|
89
109
|
|
|
90
110
|
_encodeRequestQueryParams(request) {
|
|
@@ -161,14 +181,6 @@ class ApiClient {
|
|
|
161
181
|
});
|
|
162
182
|
}
|
|
163
183
|
|
|
164
|
-
_parseResponse(response) {
|
|
165
|
-
return new Promise(
|
|
166
|
-
function (resolve, reject) {
|
|
167
|
-
resolve(response.body);
|
|
168
|
-
}
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
184
|
_signUrl (req_part) {
|
|
173
185
|
let url = '/' + this.databaseId + req_part;
|
|
174
186
|
url += (req_part.indexOf("?") == -1 ? "?" : "&" ) + "hmac_timestamp=" + parseInt(new Date().getTime() / 1000);
|
|
@@ -7,8 +7,8 @@ const ae = require("./api-error");
|
|
|
7
7
|
class ResponseError extends ae.ApiError {
|
|
8
8
|
/**
|
|
9
9
|
* Create the exception
|
|
10
|
-
* @param {Request} request -
|
|
11
|
-
* @param {number} statusCode - The
|
|
10
|
+
* @param {Request} request - Request which caused the exception
|
|
11
|
+
* @param {number} statusCode - The returned status code
|
|
12
12
|
* @param {string} message - Error message from the API
|
|
13
13
|
*/
|
|
14
14
|
constructor(request, statusCode, message) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Adds a new synonym for the [Search items](https://docs.recombee.com/api.html#search-items).
|
|
10
|
+
* When the `term` is used in the search query, the `synonym` is also used for the full-text search.
|
|
11
|
+
* Unless `oneWay=true`, it works also in the opposite way (`synonym` -> `term`).
|
|
12
|
+
* An example of a synonym can be `science fiction` for the term `sci-fi`.
|
|
13
|
+
*/
|
|
14
|
+
class AddSearchSynonym extends rqs.Request {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Construct the request
|
|
18
|
+
* @param {string} term - A word to which the `synonym` is specified.
|
|
19
|
+
* @param {string} synonym - A word that should be considered equal to the `term` by the full-text search engine.
|
|
20
|
+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
|
|
21
|
+
* - Allowed parameters:
|
|
22
|
+
* - *oneWay*
|
|
23
|
+
* - Type: boolean
|
|
24
|
+
* - Description: If set to `true`, only `term` -> `synonym` is considered. If set to `false`, also `synonym` -> `term` works.
|
|
25
|
+
* Default: `false`.
|
|
26
|
+
*/
|
|
27
|
+
constructor(term, synonym, optional) {
|
|
28
|
+
super('POST', '/synonyms/items/', 10000, false);
|
|
29
|
+
this.term = term;
|
|
30
|
+
this.synonym = synonym;
|
|
31
|
+
optional = optional || {};
|
|
32
|
+
this.oneWay = optional.oneWay;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get body parameters
|
|
37
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
38
|
+
*/
|
|
39
|
+
bodyParameters() {
|
|
40
|
+
let params = {};
|
|
41
|
+
params.term = this.term;
|
|
42
|
+
params.synonym = this.synonym;
|
|
43
|
+
|
|
44
|
+
if(this.oneWay !== undefined)
|
|
45
|
+
params.oneWay = this.oneWay;
|
|
46
|
+
|
|
47
|
+
return params;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get query parameters
|
|
52
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
53
|
+
*/
|
|
54
|
+
queryParameters() {
|
|
55
|
+
let params = {};
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.AddSearchSynonym = AddSearchSynonym
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Deletes all synonyms defined in the database.
|
|
10
|
+
*/
|
|
11
|
+
class DeleteAllSearchSynonyms extends rqs.Request {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Construct the request
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super('DELETE', '/synonyms/items/', 10000, false);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get body parameters
|
|
22
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
23
|
+
*/
|
|
24
|
+
bodyParameters() {
|
|
25
|
+
let params = {};
|
|
26
|
+
|
|
27
|
+
return params;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get query parameters
|
|
32
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
33
|
+
*/
|
|
34
|
+
queryParameters() {
|
|
35
|
+
let params = {};
|
|
36
|
+
return params;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.DeleteAllSearchSynonyms = DeleteAllSearchSynonyms
|
|
@@ -8,7 +8,7 @@ const rqs = require("./request");
|
|
|
8
8
|
/**
|
|
9
9
|
* Deletes an item of given `itemId` from the catalog.
|
|
10
10
|
* If there are any *purchases*, *ratings*, *bookmarks*, *cart additions* or *detail views* of the item present in the database, they will be deleted in cascade as well. Also, if the item is present in some *series*, it will be removed from all the *series* where present.
|
|
11
|
-
* If an item becomes obsolete/no longer available, it is
|
|
11
|
+
* If an item becomes obsolete/no longer available, it is meaningful to keep it in the catalog (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely.
|
|
12
12
|
*/
|
|
13
13
|
class DeleteItem extends rqs.Request {
|
|
14
14
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Delete all the items that pass the filter.
|
|
10
|
+
* If an item becomes obsolete/no longer available, it is meaningful to **keep it in the catalog** (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql.html) instead of deleting the item completely.
|
|
11
|
+
*/
|
|
12
|
+
class DeleteMoreItems extends rqs.Request {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Construct the request
|
|
16
|
+
* @param {string} filter - A [ReQL](https://docs.recombee.com/reql.html) expression, which return `true` for the items that shall be updated.
|
|
17
|
+
*/
|
|
18
|
+
constructor(filter) {
|
|
19
|
+
super('DELETE', '/more-items/', 1000, false);
|
|
20
|
+
this.filter = filter;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get body parameters
|
|
25
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
26
|
+
*/
|
|
27
|
+
bodyParameters() {
|
|
28
|
+
let params = {};
|
|
29
|
+
params.filter = this.filter;
|
|
30
|
+
|
|
31
|
+
return params;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get query parameters
|
|
36
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
37
|
+
*/
|
|
38
|
+
queryParameters() {
|
|
39
|
+
let params = {};
|
|
40
|
+
return params;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.DeleteMoreItems = DeleteMoreItems
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Deletes synonym of given `id` and this synonym is no longer taken into account in the [Search items](https://docs.recombee.com/api.html#search-items).
|
|
10
|
+
*/
|
|
11
|
+
class DeleteSearchSynonym extends rqs.Request {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Construct the request
|
|
15
|
+
* @param {string} id - ID of the synonym that should be deleted.
|
|
16
|
+
*/
|
|
17
|
+
constructor(id) {
|
|
18
|
+
super('DELETE', `/synonyms/items/${id}`, 10000, false);
|
|
19
|
+
this.id = id;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get body parameters
|
|
24
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
25
|
+
*/
|
|
26
|
+
bodyParameters() {
|
|
27
|
+
let params = {};
|
|
28
|
+
|
|
29
|
+
return params;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get query parameters
|
|
34
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
35
|
+
*/
|
|
36
|
+
queryParameters() {
|
|
37
|
+
let params = {};
|
|
38
|
+
return params;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.DeleteSearchSynonym = DeleteSearchSynonym
|
|
@@ -13,7 +13,7 @@ class DeleteUser extends rqs.Request {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Construct the request
|
|
16
|
-
* @param {string} userId - ID of the user to be
|
|
16
|
+
* @param {string} userId - ID of the user to be deleted.
|
|
17
17
|
*/
|
|
18
18
|
constructor(userId) {
|
|
19
19
|
super('DELETE', `/users/${userId}`, 1000, false);
|
package/lib/requests/index.js
CHANGED
|
@@ -12,6 +12,8 @@ exports.AddItemProperty = require("./add-item-property").AddItemProperty;
|
|
|
12
12
|
exports.DeleteItemProperty = require("./delete-item-property").DeleteItemProperty;
|
|
13
13
|
exports.GetItemPropertyInfo = require("./get-item-property-info").GetItemPropertyInfo;
|
|
14
14
|
exports.ListItemProperties = require("./list-item-properties").ListItemProperties;
|
|
15
|
+
exports.UpdateMoreItems = require("./update-more-items").UpdateMoreItems;
|
|
16
|
+
exports.DeleteMoreItems = require("./delete-more-items").DeleteMoreItems;
|
|
15
17
|
exports.AddSeries = require("./add-series").AddSeries;
|
|
16
18
|
exports.DeleteSeries = require("./delete-series").DeleteSeries;
|
|
17
19
|
exports.ListSeries = require("./list-series").ListSeries;
|
|
@@ -59,11 +61,14 @@ exports.DeleteViewPortion = require("./delete-view-portion").DeleteViewPortion;
|
|
|
59
61
|
exports.ListItemViewPortions = require("./list-item-view-portions").ListItemViewPortions;
|
|
60
62
|
exports.ListUserViewPortions = require("./list-user-view-portions").ListUserViewPortions;
|
|
61
63
|
exports.RecommendItemsToUser = require("./recommend-items-to-user").RecommendItemsToUser;
|
|
62
|
-
exports.RecommendUsersToUser = require("./recommend-users-to-user").RecommendUsersToUser;
|
|
63
64
|
exports.RecommendItemsToItem = require("./recommend-items-to-item").RecommendItemsToItem;
|
|
65
|
+
exports.RecommendNextItems = require("./recommend-next-items").RecommendNextItems;
|
|
66
|
+
exports.RecommendUsersToUser = require("./recommend-users-to-user").RecommendUsersToUser;
|
|
64
67
|
exports.RecommendUsersToItem = require("./recommend-users-to-item").RecommendUsersToItem;
|
|
65
68
|
exports.SearchItems = require("./search-items").SearchItems;
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
69
|
+
exports.AddSearchSynonym = require("./add-search-synonym").AddSearchSynonym;
|
|
70
|
+
exports.ListSearchSynonyms = require("./list-search-synonyms").ListSearchSynonyms;
|
|
71
|
+
exports.DeleteAllSearchSynonyms = require("./delete-all-search-synonyms").DeleteAllSearchSynonyms;
|
|
72
|
+
exports.DeleteSearchSynonym = require("./delete-search-synonym").DeleteSearchSynonym;
|
|
68
73
|
exports.ResetDatabase = require("./reset-database").ResetDatabase;
|
|
69
74
|
exports.Batch = require("./batch").Batch;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Gives the list of synonyms defined in the database.
|
|
10
|
+
*/
|
|
11
|
+
class ListSearchSynonyms extends rqs.Request {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Construct the request
|
|
15
|
+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
|
|
16
|
+
* - Allowed parameters:
|
|
17
|
+
* - *count*
|
|
18
|
+
* - Type: number
|
|
19
|
+
* - Description: The number of synonyms to be listed.
|
|
20
|
+
* - *offset*
|
|
21
|
+
* - Type: number
|
|
22
|
+
* - Description: Specifies the number of synonyms to skip (ordered by `term`).
|
|
23
|
+
*/
|
|
24
|
+
constructor(optional) {
|
|
25
|
+
super('GET', '/synonyms/items/', 100000, false);
|
|
26
|
+
optional = optional || {};
|
|
27
|
+
this.count = optional.count;
|
|
28
|
+
this.offset = optional.offset;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get body parameters
|
|
33
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
34
|
+
*/
|
|
35
|
+
bodyParameters() {
|
|
36
|
+
let params = {};
|
|
37
|
+
|
|
38
|
+
return params;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get query parameters
|
|
43
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
44
|
+
*/
|
|
45
|
+
queryParameters() {
|
|
46
|
+
let params = {};
|
|
47
|
+
if (this.count !== undefined)
|
|
48
|
+
params.count = this.count;
|
|
49
|
+
if (this.offset !== undefined)
|
|
50
|
+
params.offset = this.offset;
|
|
51
|
+
return params;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.ListSearchSynonyms = ListSearchSynonyms
|
|
@@ -7,8 +7,11 @@ const rqs = require("./request");
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Recommends set of items that are somehow related to one given item, *X*. Typical scenario is when user *A* is viewing *X*. Then you may display items to the user that he might be also interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account.
|
|
10
|
+
* The returned items are sorted by relevance (first item being the most relevant).
|
|
11
|
+
* Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
12
|
+
* - Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
|
|
13
|
+
* - Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
|
|
10
14
|
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
11
|
-
* The returned items are sorted by relevancy (first item being the most relevant).
|
|
12
15
|
*/
|
|
13
16
|
class RecommendItemsToItem extends rqs.Request {
|
|
14
17
|
|
|
@@ -66,7 +69,8 @@ class RecommendItemsToItem extends rqs.Request {
|
|
|
66
69
|
* "url": "myshop.com/mixer-42"
|
|
67
70
|
* }
|
|
68
71
|
* }
|
|
69
|
-
* ]
|
|
72
|
+
* ],
|
|
73
|
+
* "numberNextRecommsCalls": 0
|
|
70
74
|
* }
|
|
71
75
|
* ```
|
|
72
76
|
* - *includedProperties*
|
|
@@ -92,7 +96,8 @@ class RecommendItemsToItem extends rqs.Request {
|
|
|
92
96
|
* "price": 39
|
|
93
97
|
* }
|
|
94
98
|
* }
|
|
95
|
-
* ]
|
|
99
|
+
* ],
|
|
100
|
+
* "numberNextRecommsCalls": 0
|
|
96
101
|
* }
|
|
97
102
|
* ```
|
|
98
103
|
* - *filter*
|
|
@@ -117,7 +122,7 @@ class RecommendItemsToItem extends rqs.Request {
|
|
|
117
122
|
* - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
|
|
118
123
|
* - *minRelevance*
|
|
119
124
|
* - Type: string
|
|
120
|
-
* - Description: **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested
|
|
125
|
+
* - Description: **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance, and may return less than *count* items when there is not enough data to fulfill it.
|
|
121
126
|
* - *rotationRate*
|
|
122
127
|
* - Type: number
|
|
123
128
|
* - Description: **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items.
|
|
@@ -8,8 +8,11 @@ const rqs = require("./request");
|
|
|
8
8
|
/**
|
|
9
9
|
* Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user.
|
|
10
10
|
* The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email.
|
|
11
|
+
* The returned items are sorted by relevance (first item being the most relevant).
|
|
12
|
+
* Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
13
|
+
* - Let Recombee know that this recommendation was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
|
|
14
|
+
* - Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
|
|
11
15
|
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
12
|
-
* The returned items are sorted by relevancy (first item being the most relevant).
|
|
13
16
|
*/
|
|
14
17
|
class RecommendItemsToUser extends rqs.Request {
|
|
15
18
|
|
|
@@ -54,7 +57,8 @@ class RecommendItemsToUser extends rqs.Request {
|
|
|
54
57
|
* "url": "myshop.com/mixer-42"
|
|
55
58
|
* }
|
|
56
59
|
* }
|
|
57
|
-
* ]
|
|
60
|
+
* ],
|
|
61
|
+
* "numberNextRecommsCalls": 0
|
|
58
62
|
* }
|
|
59
63
|
* ```
|
|
60
64
|
* - *includedProperties*
|
|
@@ -80,7 +84,8 @@ class RecommendItemsToUser extends rqs.Request {
|
|
|
80
84
|
* "price": 39
|
|
81
85
|
* }
|
|
82
86
|
* }
|
|
83
|
-
* ]
|
|
87
|
+
* ],
|
|
88
|
+
* "numberNextRecommsCalls": 0
|
|
84
89
|
* }
|
|
85
90
|
* ```
|
|
86
91
|
* - *filter*
|
|
@@ -102,10 +107,10 @@ class RecommendItemsToUser extends rqs.Request {
|
|
|
102
107
|
* - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
|
|
103
108
|
* - *minRelevance*
|
|
104
109
|
* - Type: string
|
|
105
|
-
* - Description: **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested
|
|
110
|
+
* - Description: **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance, and may return less than *count* items when there is not enough data to fulfill it.
|
|
106
111
|
* - *rotationRate*
|
|
107
112
|
* - Type: number
|
|
108
|
-
* - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0
|
|
113
|
+
* - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0`.
|
|
109
114
|
* - *rotationTime*
|
|
110
115
|
* - Type: number
|
|
111
116
|
* - Description: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is auto-generated, do not edit
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const rqs = require("./request");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (*infinite scroll*) or goes to a next page.
|
|
10
|
+
* It accepts `recommId` of a base recommendation request (e.g. request from the first page) and number of items that shall be returned (`count`).
|
|
11
|
+
* The base request can be one of:
|
|
12
|
+
* - [Recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item)
|
|
13
|
+
* - [Recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user)
|
|
14
|
+
* - [Search items](https://docs.recombee.com/api.html#search-items)
|
|
15
|
+
* All the other parameters are inherited from the base request.
|
|
16
|
+
* *Recommend next items* can be called many times for a single `recommId` and each call returns different (previously not recommended) items.
|
|
17
|
+
* The number of *Recommend next items* calls performed so far is returned in the `numberNextRecommsCalls` field.
|
|
18
|
+
* *Recommend next items* can be requested up to 30 minutes after the base request or a previous *Recommend next items* call.
|
|
19
|
+
* For billing purposes, each call to *Recommend next items* is counted as a separate recommendation request.
|
|
20
|
+
*/
|
|
21
|
+
class RecommendNextItems extends rqs.Request {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Construct the request
|
|
25
|
+
* @param {string} recommId - ID of the base recommendation request for which next recommendations should be returned
|
|
26
|
+
* @param {number} count - Number of items to be recommended
|
|
27
|
+
*/
|
|
28
|
+
constructor(recommId, count) {
|
|
29
|
+
super('POST', `/recomms/next/items/${recommId}`, 3000, false);
|
|
30
|
+
this.recommId = recommId;
|
|
31
|
+
this.count = count;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get body parameters
|
|
36
|
+
* @return {Object} The values of body parameters (name of parameter: value of the parameter)
|
|
37
|
+
*/
|
|
38
|
+
bodyParameters() {
|
|
39
|
+
let params = {};
|
|
40
|
+
params.count = this.count;
|
|
41
|
+
|
|
42
|
+
return params;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get query parameters
|
|
47
|
+
* @return {Object} The values of query parameters (name of parameter: value of the parameter)
|
|
48
|
+
*/
|
|
49
|
+
queryParameters() {
|
|
50
|
+
let params = {};
|
|
51
|
+
return params;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.RecommendNextItems = RecommendNextItems
|