Skip to content

Commit 26792c2

Browse files
committed
Release: v5.0.0
- Support new Recommend Items to Item Segment endpoint - Series API improvements: - Add Series endpoint creates associated Item for the Series automatically (based on the cascadeCreate parameter) - Breaking change: Remove From Series no longer requires the time parameter - Removed deprecated Groups endpoints
1 parent fcf2be3 commit 26792c2

19 files changed

+577
-155
lines changed

lib/api-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ApiClient {
4343
method: request.method,
4444
headers: {'Accept': 'application/json',
4545
'Content-Type': 'application/json',
46-
'User-Agent': 'recombee-node-api-client/4.1.5'},
46+
'User-Agent': 'recombee-node-api-client/5.0.0'},
4747
timeout: request.timeout,
4848
agent: this.options.agent
4949
};

lib/index.d.ts

Lines changed: 123 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -664,15 +664,22 @@ export module "recombee-api-client" {
664664
export class AddSeries extends requests.Request {
665665
/**
666666
* @param seriesId - ID of the series to be created.
667+
* @param optional - Optional parameters given as an object.
667668
*/
668669
constructor(
669670
seriesId: string,
671+
optional?: {
672+
/** If set to `true`, the item will be created with the same ID as the series. Default is `true`. */
673+
cascadeCreate?: boolean;
674+
}
670675
);
671676

672677
seriesId: string;
678+
cascadeCreate?: boolean;
673679
protected __response_type: string;
674680

675681
bodyParameters(): {
682+
cascadeCreate?: boolean;
676683
};
677684

678685
queryParameters(): {
@@ -686,15 +693,22 @@ export module "recombee-api-client" {
686693
export class DeleteSeries extends requests.Request {
687694
/**
688695
* @param seriesId - ID of the series to be deleted.
696+
* @param optional - Optional parameters given as an object.
689697
*/
690698
constructor(
691699
seriesId: string,
700+
optional?: {
701+
/** If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`. */
702+
cascadeDelete?: boolean;
703+
}
692704
);
693705

694706
seriesId: string;
707+
cascadeDelete?: boolean;
695708
protected __response_type: string;
696709

697710
bodyParameters(): {
711+
cascadeDelete?: boolean;
698712
};
699713

700714
queryParameters(): {
@@ -758,7 +772,7 @@ export module "recombee-api-client" {
758772
itemId: string,
759773
time: number,
760774
optional?: {
761-
/** Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either item or series may be created if not present in the database. */
775+
/** Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created. */
762776
cascadeCreate?: boolean;
763777
}
764778
);
@@ -789,28 +803,24 @@ export module "recombee-api-client" {
789803
* @param seriesId - ID of the series from which a series item is to be removed.
790804
* @param itemType - Type of the item to be removed.
791805
* @param itemId - ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
792-
* @param time - Time index of the item to be removed.
793806
*/
794807
constructor(
795808
seriesId: string,
796809
itemType: string,
797810
itemId: string,
798-
time: number,
799811
);
800812

801813
seriesId: string;
802814
itemType: string;
803815
itemId: string;
804-
time: number;
805816
protected __response_type: string;
806817

807818
bodyParameters(): {
819+
itemType: string;
820+
itemId: string;
808821
};
809822

810823
queryParameters(): {
811-
itemType: string;
812-
itemId: string;
813-
time: number;
814824
};
815825
}
816826

@@ -2179,13 +2189,13 @@ export module "recombee-api-client" {
21792189
}
21802190

21812191
/**
2182-
* Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions.
2192+
* Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) for a particular user, based on the user's past interactions.
21832193
* Based on the used Segmentation, this endpoint can be used for example for:
21842194
* - Recommending the top categories for the user
21852195
* - Recommending the top genres for the user
21862196
* - Recommending the top brands for the user
21872197
* - Recommending the top artists for the user
2188-
* You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
2198+
* You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
21892199
* The returned segments are sorted by relevance (first segment being the most relevant).
21902200
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
21912201
*/
@@ -2243,13 +2253,13 @@ export module "recombee-api-client" {
22432253
}
22442254

22452255
/**
2246-
* Recommends Segments from a Segmentation that are the most relevant to a particular item.
2256+
* Recommends Segments from a [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular item.
22472257
* Based on the used Segmentation, this endpoint can be used for example for:
22482258
* - Recommending the related categories
22492259
* - Recommending the related genres
22502260
* - Recommending the related brands
22512261
* - Recommending the related artists
2252-
* You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
2262+
* You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
22532263
* The returned segments are sorted by relevance (first segment being the most relevant).
22542264
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
22552265
*/
@@ -2323,12 +2333,12 @@ export module "recombee-api-client" {
23232333
}
23242334

23252335
/**
2326-
* Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation.
2336+
* Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular Segment from a context Segmentation.
23272337
* Based on the used Segmentations, this endpoint can be used for example for:
23282338
* - Recommending the related brands to particular brand
23292339
* - Recommending the related brands to particular category
23302340
* - Recommending the related artists to a particular genre (assuming songs are the Items)
2331-
* You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
2341+
* You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
23322342
* The returned segments are sorted by relevance (first segment being the most relevant).
23332343
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
23342344
*/
@@ -2402,6 +2412,106 @@ export module "recombee-api-client" {
24022412
};
24032413
}
24042414

2415+
/**
2416+
* Recommends Items that are the most relevant to a particular Segment from a context [Segmentation](https://docs.recombee.com/segmentations.html).
2417+
* Based on the used Segmentation, this endpoint can be used for example for:
2418+
* - Recommending articles related to a particular topic
2419+
* - Recommending songs belonging to a particular genre
2420+
* - Recommending products produced by a particular brand
2421+
* You need to set the used context Segmentation in the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
2422+
* The returned items are sorted by relevance (the first item being the most relevant).
2423+
* It is also possible to use the POST HTTP method (for example, in the case of a very long ReQL filter) — query parameters then become body parameters.
2424+
*/
2425+
export class RecommendItemsToItemSegment extends requests.Request {
2426+
/**
2427+
* @param contextSegmentId - ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
2428+
* @param targetUserId - ID of the user who will see the recommendations.
2429+
* Specifying the *targetUserId* is beneficial because:
2430+
* * It makes the recommendations personalized
2431+
* * Allows the calculation of Actions and Conversions
2432+
* in the graphical user interface,
2433+
* as Recombee can pair the user who got recommendations
2434+
* and who afterward viewed/purchased an item.
2435+
* If you insist on not specifying the user, pass `null`
2436+
* (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
2437+
* Do not create some special dummy user for getting recommendations,
2438+
* as it could mislead the recommendation models,
2439+
* and result in wrong recommendations.
2440+
* For anonymous/unregistered users, it is possible to use, for example, their session ID.
2441+
* @param count - Number of items to be recommended (N for the top-N recommendation).
2442+
* @param optional - Optional parameters given as an object.
2443+
*/
2444+
constructor(
2445+
contextSegmentId: string,
2446+
targetUserId: string,
2447+
count: number,
2448+
optional?: {
2449+
/** Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". */
2450+
scenario?: string;
2451+
/** If an item of the given *itemId* or user of the given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given *targetUserId*, as the user will be already known to the system. */
2452+
cascadeCreate?: boolean;
2453+
/** With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user. */
2454+
returnProperties?: boolean;
2455+
/** Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. */
2456+
includedProperties?: string[];
2457+
/** Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to filter recommended items based on the values of their attributes. */
2458+
filter?: string;
2459+
/** Number-returning [ReQL](https://docs.recombee.com/reql.html) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes. */
2460+
booster?: string;
2461+
/** Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. */
2462+
logic?: string | object;
2463+
/** **Expert option** If the *targetUserId* is provided: Specifies the threshold of how 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 a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being 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. */
2464+
minRelevance?: string;
2465+
/** **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 a 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. */
2466+
rotationRate?: number;
2467+
/** **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. */
2468+
rotationTime?: number;
2469+
/** Dictionary of custom options. */
2470+
expertSettings?: { [key: string]: unknown };
2471+
/** If there is a custom AB-testing running, return the name of the group to which the request belongs. */
2472+
returnAbGroup?: boolean;
2473+
}
2474+
);
2475+
2476+
contextSegmentId: string;
2477+
targetUserId: string;
2478+
count: number;
2479+
scenario?: string;
2480+
cascadeCreate?: boolean;
2481+
returnProperties?: boolean;
2482+
includedProperties?: string[];
2483+
filter?: string;
2484+
booster?: string;
2485+
logic?: string | object;
2486+
minRelevance?: string;
2487+
rotationRate?: number;
2488+
rotationTime?: number;
2489+
expertSettings?: { [key: string]: unknown };
2490+
returnAbGroup?: boolean;
2491+
protected __response_type: RecommendationResponse;
2492+
2493+
bodyParameters(): {
2494+
contextSegmentId: string;
2495+
targetUserId: string;
2496+
count: number;
2497+
scenario?: string;
2498+
cascadeCreate?: boolean;
2499+
returnProperties?: boolean;
2500+
includedProperties?: string[];
2501+
filter?: string;
2502+
booster?: string;
2503+
logic?: string | object;
2504+
minRelevance?: string;
2505+
rotationRate?: number;
2506+
rotationTime?: number;
2507+
expertSettings?: { [key: string]: unknown };
2508+
returnAbGroup?: boolean;
2509+
};
2510+
2511+
queryParameters(): {
2512+
};
2513+
}
2514+
24052515
/**
24062516
* Full-text personalized search. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.) with the items (items more suitable for the user are preferred in the results).
24072517
* All the string and set item properties are indexed by the search engine.

lib/requests/add-series.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ class AddSeries extends rqs.Request {
1313
/**
1414
* Construct the request
1515
* @param {string} seriesId - ID of the series to be created.
16+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
17+
* - Allowed parameters:
18+
* - *cascadeCreate*
19+
* - Type: boolean
20+
* - Description: If set to `true`, the item will be created with the same ID as the series. Default is `true`.
1621
*/
17-
constructor(seriesId) {
22+
constructor(seriesId, optional) {
1823
super('PUT', `/series/${seriesId}`, 3000, false);
1924
this.seriesId = seriesId;
25+
optional = optional || {};
26+
this.cascadeCreate = optional.cascadeCreate;
2027
}
2128

2229
/**
@@ -26,6 +33,9 @@ class AddSeries extends rqs.Request {
2633
bodyParameters() {
2734
let params = {};
2835

36+
if(this.cascadeCreate !== undefined)
37+
params.cascadeCreate = this.cascadeCreate;
38+
2939
return params;
3040
}
3141

lib/requests/delete-series.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ class DeleteSeries extends rqs.Request {
1414
/**
1515
* Construct the request
1616
* @param {string} seriesId - ID of the series to be deleted.
17+
* @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
18+
* - Allowed parameters:
19+
* - *cascadeDelete*
20+
* - Type: boolean
21+
* - Description: If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`.
1722
*/
18-
constructor(seriesId) {
23+
constructor(seriesId, optional) {
1924
super('DELETE', `/series/${seriesId}`, 3000, false);
2025
this.seriesId = seriesId;
26+
optional = optional || {};
27+
this.cascadeDelete = optional.cascadeDelete;
2128
}
2229

2330
/**
@@ -27,6 +34,9 @@ class DeleteSeries extends rqs.Request {
2734
bodyParameters() {
2835
let params = {};
2936

37+
if(this.cascadeDelete !== undefined)
38+
params.cascadeDelete = this.cascadeDelete;
39+
3040
return params;
3141
}
3242

lib/requests/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ exports.RecommendUsersToItem = require("./recommend-users-to-item").RecommendUse
6262
exports.RecommendItemSegmentsToUser = require("./recommend-item-segments-to-user").RecommendItemSegmentsToUser;
6363
exports.RecommendItemSegmentsToItem = require("./recommend-item-segments-to-item").RecommendItemSegmentsToItem;
6464
exports.RecommendItemSegmentsToItemSegment = require("./recommend-item-segments-to-item-segment").RecommendItemSegmentsToItemSegment;
65+
exports.RecommendItemsToItemSegment = require("./recommend-items-to-item-segment").RecommendItemsToItemSegment;
6566
exports.SearchItems = require("./search-items").SearchItems;
6667
exports.SearchItemSegments = require("./search-item-segments").SearchItemSegments;
6768
exports.AddSearchSynonym = require("./add-search-synonym").AddSearchSynonym;

lib/requests/insert-to-series.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InsertToSeries extends rqs.Request {
2020
* - Allowed parameters:
2121
* - *cascadeCreate*
2222
* - Type: boolean
23-
* - Description: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either item or series may be created if not present in the database.
23+
* - Description: Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created.
2424
*/
2525
constructor(seriesId, itemType, itemId, time, optional) {
2626
super('POST', `/series/${seriesId}/items/`, 3000, false);

lib/requests/recommend-item-segments-to-item-segment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
const rqs = require("./request");
77

88
/**
9-
* Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation.
9+
* Recommends Segments from a result [Segmentation](https://docs.recombee.com/segmentations.html) that are the most relevant to a particular Segment from a context Segmentation.
1010
* Based on the used Segmentations, this endpoint can be used for example for:
1111
* - Recommending the related brands to particular brand
1212
* - Recommending the related brands to particular category
1313
* - Recommending the related artists to a particular genre (assuming songs are the Items)
14-
* You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
14+
* You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
1515
* The returned segments are sorted by relevance (first segment being the most relevant).
1616
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
1717
*/

0 commit comments

Comments
 (0)