Skip to content

Commit 904c986

Browse files
committed
additionalData for interactions, returnAbGroup for recommendation endpoints
1 parent dd7d2c2 commit 904c986

31 files changed

+98
-23
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Recombee API Client
22

33
A Node.js client (SDK) for easy use of the [Recombee](https://www.recombee.com/) recommendation API.
4-
54
If you don't have an account at Recombee yet, you can create a free account [here](https://www.recombee.com/).
65

76
Documentation of the API can be found at [docs.recombee.com](https://docs.recombee.com/).
87

8+
For client side (browser, mobile apps ...) .js library please see [this repository](https://github.com/recombee/js-api-client).
9+
910
## Installation
1011

1112
```
@@ -43,7 +44,7 @@ client.send(new AddDetailView,
4344
var recombee = require('recombee-api-client');
4445
var rqs = recombee.requests;
4546

46-
var client = new recombee.ApiClient('--my-database-id--', '--my-secret-token--');
47+
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--');
4748

4849
// Prepare some userIDs and itemIDs
4950
const NUM = 100;
@@ -89,7 +90,7 @@ client.send(new rqs.Batch(purchases))
8990
var recombee = require('recombee-api-client');
9091
var rqs = recombee.requests;
9192

92-
var client = new recombee.ApiClient('--my-database-id--', '--my-secret-token--');
93+
var client = new recombee.ApiClient('--my-database-id--', '--db-private-token--');
9394
const NUM = 100;
9495

9596
// We will use computers as items in this example

lib/api-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ApiClient {
4444
uri: url,
4545
headers: {'Accept': 'application/json',
4646
'Content-Type': 'application/json',
47-
'User-Agent': 'recombee-node-api-client/2.2.0'},
47+
'User-Agent': 'recombee-node-api-client/2.3.0'},
4848
timeout: request.timeout,
4949
resolveWithFullResponse: true,
5050
json: true

lib/requests/add-bookmark.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class AddBookmark extends rqs.Request {
2525
* - *recommId*
2626
* - Type: string
2727
* - Description: If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
28+
* - *additionalData*
29+
* - Type:
30+
* - Description: A dictionary of additional data for the interaction.
2831
*/
2932
constructor(userId, itemId, optional) {
3033
super('POST', '/bookmarks/', 1000, false);
@@ -34,6 +37,7 @@ class AddBookmark extends rqs.Request {
3437
this.timestamp = optional.timestamp;
3538
this.cascadeCreate = optional.cascadeCreate;
3639
this.recommId = optional.recommId;
40+
this.additionalData = optional.additionalData;
3741
}
3842

3943
/**
@@ -54,6 +58,9 @@ class AddBookmark extends rqs.Request {
5458
if(this.recommId !== undefined)
5559
params.recommId = this.recommId;
5660

61+
if(this.additionalData !== undefined)
62+
params.additionalData = this.additionalData;
63+
5764
return params;
5865
}
5966

lib/requests/add-cart-addition.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class AddCartAddition extends rqs.Request {
3131
* - *recommId*
3232
* - Type: string
3333
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
34+
* - *additionalData*
35+
* - Type:
36+
* - Description: A dictionary of additional data for the interaction.
3437
*/
3538
constructor(userId, itemId, optional) {
3639
super('POST', '/cartadditions/', 1000, false);
@@ -42,6 +45,7 @@ class AddCartAddition extends rqs.Request {
4245
this.amount = optional.amount;
4346
this.price = optional.price;
4447
this.recommId = optional.recommId;
48+
this.additionalData = optional.additionalData;
4549
}
4650

4751
/**
@@ -68,6 +72,9 @@ class AddCartAddition extends rqs.Request {
6872
if(this.recommId !== undefined)
6973
params.recommId = this.recommId;
7074

75+
if(this.additionalData !== undefined)
76+
params.additionalData = this.additionalData;
77+
7178
return params;
7279
}
7380

lib/requests/add-detail-view.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class AddDetailView extends rqs.Request {
2828
* - *recommId*
2929
* - Type: string
3030
* - Description: If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
31+
* - *additionalData*
32+
* - Type:
33+
* - Description: A dictionary of additional data for the interaction.
3134
*/
3235
constructor(userId, itemId, optional) {
3336
super('POST', '/detailviews/', 1000, false);
@@ -38,6 +41,7 @@ class AddDetailView extends rqs.Request {
3841
this.duration = optional.duration;
3942
this.cascadeCreate = optional.cascadeCreate;
4043
this.recommId = optional.recommId;
44+
this.additionalData = optional.additionalData;
4145
}
4246

4347
/**
@@ -61,6 +65,9 @@ class AddDetailView extends rqs.Request {
6165
if(this.recommId !== undefined)
6266
params.recommId = this.recommId;
6367

68+
if(this.additionalData !== undefined)
69+
params.additionalData = this.additionalData;
70+
6471
return params;
6572
}
6673

lib/requests/add-purchase.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class AddPurchase extends rqs.Request {
3434
* - *recommId*
3535
* - Type: string
3636
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
37+
* - *additionalData*
38+
* - Type:
39+
* - Description: A dictionary of additional data for the interaction.
3740
*/
3841
constructor(userId, itemId, optional) {
3942
super('POST', '/purchases/', 1000, false);
@@ -46,6 +49,7 @@ class AddPurchase extends rqs.Request {
4649
this.price = optional.price;
4750
this.profit = optional.profit;
4851
this.recommId = optional.recommId;
52+
this.additionalData = optional.additionalData;
4953
}
5054

5155
/**
@@ -75,6 +79,9 @@ class AddPurchase extends rqs.Request {
7579
if(this.recommId !== undefined)
7680
params.recommId = this.recommId;
7781

82+
if(this.additionalData !== undefined)
83+
params.additionalData = this.additionalData;
84+
7885
return params;
7986
}
8087

lib/requests/add-rating.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class AddRating extends rqs.Request {
2626
* - *recommId*
2727
* - Type: string
2828
* - Description: If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
29+
* - *additionalData*
30+
* - Type:
31+
* - Description: A dictionary of additional data for the interaction.
2932
*/
3033
constructor(userId, itemId, rating, optional) {
3134
super('POST', '/ratings/', 1000, false);
@@ -36,6 +39,7 @@ class AddRating extends rqs.Request {
3639
this.timestamp = optional.timestamp;
3740
this.cascadeCreate = optional.cascadeCreate;
3841
this.recommId = optional.recommId;
42+
this.additionalData = optional.additionalData;
3943
}
4044

4145
/**
@@ -57,6 +61,9 @@ class AddRating extends rqs.Request {
5761
if(this.recommId !== undefined)
5862
params.recommId = this.recommId;
5963

64+
if(this.additionalData !== undefined)
65+
params.additionalData = this.additionalData;
66+
6067
return params;
6168
}
6269

lib/requests/recommend-items-to-item.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rqs = require("./request");
88
/**
99
* 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.
1010
* 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).
1112
*/
1213
class RecommendItemsToItem extends rqs.Request {
1314

@@ -116,6 +117,9 @@ class RecommendItemsToItem extends rqs.Request {
116117
* - *expertSettings*
117118
* - Type:
118119
* - Description: Dictionary of custom options.
120+
* - *returnAbGroup*
121+
* - Type: boolean
122+
* - Description: If there is a custom AB-testing running, return name of group to which the request belongs.
119123
*/
120124
constructor(itemId, targetUserId, count, optional) {
121125
super('POST', `/recomms/items/${itemId}/items/`, 3000, false);
@@ -135,6 +139,7 @@ class RecommendItemsToItem extends rqs.Request {
135139
this.rotationRate = optional.rotationRate;
136140
this.rotationTime = optional.rotationTime;
137141
this.expertSettings = optional.expertSettings;
142+
this.returnAbGroup = optional.returnAbGroup;
138143
}
139144

140145
/**
@@ -182,6 +187,9 @@ class RecommendItemsToItem extends rqs.Request {
182187
if(this.expertSettings !== undefined)
183188
params.expertSettings = this.expertSettings;
184189

190+
if(this.returnAbGroup !== undefined)
191+
params.returnAbGroup = this.returnAbGroup;
192+
185193
return params;
186194
}
187195

lib/requests/recommend-items-to-user.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rqs = require("./request");
88
/**
99
* 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.
1010
* 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).
1112
*/
1213
class RecommendItemsToUser extends rqs.Request {
1314

@@ -100,6 +101,9 @@ class RecommendItemsToUser extends rqs.Request {
100101
* - *expertSettings*
101102
* - Type:
102103
* - Description: Dictionary of custom options.
104+
* - *returnAbGroup*
105+
* - Type: boolean
106+
* - Description: If there is a custom AB-testing running, return name of group to which the request belongs.
103107
*/
104108
constructor(userId, count, optional) {
105109
super('POST', `/recomms/users/${userId}/items/`, 3000, false);
@@ -117,6 +121,7 @@ class RecommendItemsToUser extends rqs.Request {
117121
this.rotationRate = optional.rotationRate;
118122
this.rotationTime = optional.rotationTime;
119123
this.expertSettings = optional.expertSettings;
124+
this.returnAbGroup = optional.returnAbGroup;
120125
}
121126

122127
/**
@@ -160,6 +165,9 @@ class RecommendItemsToUser extends rqs.Request {
160165
if(this.expertSettings !== undefined)
161166
params.expertSettings = this.expertSettings;
162167

168+
if(this.returnAbGroup !== undefined)
169+
params.returnAbGroup = this.returnAbGroup;
170+
163171
return params;
164172
}
165173

lib/requests/recommend-users-to-item.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rqs = require("./request");
88
/**
99
* Recommend users that are likely to be interested in a given item.
1010
* 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 users are sorted by predicted interest in the item (first user being the most interested).
1112
*/
1213
class RecommendUsersToItem extends rqs.Request {
1314

@@ -85,6 +86,9 @@ class RecommendUsersToItem extends rqs.Request {
8586
* - *expertSettings*
8687
* - Type:
8788
* - Description: Dictionary of custom options.
89+
* - *returnAbGroup*
90+
* - Type: boolean
91+
* - Description: If there is a custom AB-testing running, return name of group to which the request belongs.
8892
*/
8993
constructor(itemId, count, optional) {
9094
super('POST', `/recomms/items/${itemId}/users/`, 50000, false);
@@ -99,6 +103,7 @@ class RecommendUsersToItem extends rqs.Request {
99103
this.includedProperties = optional.includedProperties;
100104
this.diversity = optional.diversity;
101105
this.expertSettings = optional.expertSettings;
106+
this.returnAbGroup = optional.returnAbGroup;
102107
}
103108

104109
/**
@@ -133,6 +138,9 @@ class RecommendUsersToItem extends rqs.Request {
133138
if(this.expertSettings !== undefined)
134139
params.expertSettings = this.expertSettings;
135140

141+
if(this.returnAbGroup !== undefined)
142+
params.returnAbGroup = this.returnAbGroup;
143+
136144
return params;
137145
}
138146

0 commit comments

Comments
 (0)