recombee-api-client 4.1.5 → 5.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/index.js +1 -1
- package/lib/api-client.js +20 -15
- package/lib/errors/index.js +1 -1
- package/lib/index.d.ts +127 -175
- package/lib/requests/add-bookmark.js +1 -1
- package/lib/requests/add-cart-addition.js +1 -1
- package/lib/requests/add-detail-view.js +1 -1
- package/lib/requests/add-item-property.js +1 -1
- package/lib/requests/add-item.js +1 -1
- package/lib/requests/add-purchase.js +1 -1
- package/lib/requests/add-rating.js +1 -1
- package/lib/requests/add-series.js +12 -2
- package/lib/requests/add-user-property.js +1 -1
- package/lib/requests/add-user.js +1 -1
- package/lib/requests/delete-bookmark.js +1 -1
- package/lib/requests/delete-cart-addition.js +1 -1
- package/lib/requests/delete-detail-view.js +1 -1
- package/lib/requests/delete-item.js +1 -1
- package/lib/requests/delete-purchase.js +1 -1
- package/lib/requests/delete-rating.js +1 -1
- package/lib/requests/delete-series.js +12 -2
- package/lib/requests/delete-user.js +1 -1
- package/lib/requests/delete-view-portion.js +1 -1
- package/lib/requests/get-item-property-info.js +1 -1
- package/lib/requests/get-item-values.js +1 -1
- package/lib/requests/get-user-values.js +1 -1
- package/lib/requests/index.js +1 -6
- package/lib/requests/insert-to-series.js +2 -2
- package/lib/requests/recommend-item-segments-to-item-segment.js +2 -2
- package/lib/requests/recommend-item-segments-to-item.js +2 -2
- package/lib/requests/recommend-item-segments-to-user.js +2 -2
- package/lib/requests/recommend-items-to-item-segment.js +214 -0
- package/lib/requests/remove-from-series.js +4 -7
- package/lib/requests/request.js +1 -1
- package/lib/requests/set-view-portion.js +1 -1
- package/package.json +8 -5
- package/test/add-bookmark-batch_test.js +2 -4
- package/test/add-bookmark-callback_test.js +0 -15
- package/test/add-bookmark-test.js +0 -17
- package/test/add-cart-addition-batch_test.js +2 -4
- package/test/add-cart-addition-callback_test.js +0 -15
- package/test/add-cart-addition-test.js +0 -17
- package/test/add-detail-view-batch_test.js +2 -4
- package/test/add-detail-view-callback_test.js +0 -15
- package/test/add-detail-view-test.js +0 -17
- package/test/add-purchase-batch_test.js +2 -4
- package/test/add-purchase-callback_test.js +0 -15
- package/test/add-purchase-test.js +0 -17
- package/test/add-rating-batch_test.js +2 -4
- package/test/add-rating-callback_test.js +0 -15
- package/test/add-rating-test.js +0 -17
- package/test/list-items-batch_test.js +1 -1
- package/test/list-items-callback_test.js +1 -1
- package/test/list-items-test.js +1 -1
- package/test/list-users-batch_test.js +1 -1
- package/test/list-users-callback_test.js +1 -1
- package/test/list-users-test.js +1 -1
- package/test/{list-groups-batch_test.js → recommend-items-to-item-segment-batch_test.js} +4 -5
- package/test/{list-groups-callback_test.js → recommend-items-to-item-segment-callback_test.js} +8 -7
- package/test/{remove-from-group-test.js → recommend-items-to-item-segment-test.js} +5 -14
- package/test/remove-from-series-batch_test.js +4 -6
- package/test/remove-from-series-callback_test.js +2 -17
- package/test/remove-from-series-test.js +2 -19
- package/test/set-environment.js +89 -86
- package/test/set-view-portion-batch_test.js +0 -2
- package/test/set-view-portion-callback_test.js +0 -15
- package/test/set-view-portion-test.js +0 -17
- package/lib/requests/add-group.js +0 -42
- package/lib/requests/delete-group.js +0 -43
- package/lib/requests/insert-to-group.js +0 -58
- package/lib/requests/list-group-items.js +0 -42
- package/lib/requests/list-groups.js +0 -40
- package/lib/requests/remove-from-group.js +0 -48
- package/test/add-group-batch_test.js +0 -39
- package/test/add-group-callback_test.js +0 -72
- package/test/add-group-test.js +0 -68
- package/test/delete-group-batch_test.js +0 -39
- package/test/delete-group-callback_test.js +0 -74
- package/test/delete-group-test.js +0 -76
- package/test/insert-to-group-batch_test.js +0 -53
- package/test/insert-to-group-callback_test.js +0 -86
- package/test/insert-to-group-test.js +0 -68
- package/test/list-group-items-batch_test.js +0 -36
- package/test/list-group-items-callback_test.js +0 -38
- package/test/list-group-items-test.js +0 -34
- package/test/list-groups-test.js +0 -32
- package/test/remove-from-group-batch_test.js +0 -35
- package/test/remove-from-group-callback_test.js +0 -50
package/index.js
CHANGED
package/lib/api-client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const jsSHA = require("jssha");
|
|
4
|
-
const got = require('got');
|
|
5
4
|
|
|
6
5
|
const api_errors = require('./errors');
|
|
7
6
|
const requests = require('./requests');
|
|
@@ -42,10 +41,9 @@ class ApiClient {
|
|
|
42
41
|
let url = this._buildRequestUrl(request);
|
|
43
42
|
let options = {
|
|
44
43
|
method: request.method,
|
|
45
|
-
url: url,
|
|
46
44
|
headers: {'Accept': 'application/json',
|
|
47
45
|
'Content-Type': 'application/json',
|
|
48
|
-
'User-Agent': 'recombee-node-api-client/
|
|
46
|
+
'User-Agent': 'recombee-node-api-client/5.0.0'},
|
|
49
47
|
timeout: request.timeout,
|
|
50
48
|
agent: this.options.agent
|
|
51
49
|
};
|
|
@@ -53,7 +51,8 @@ class ApiClient {
|
|
|
53
51
|
if (Object.entries(request.bodyParameters()).length > 0)
|
|
54
52
|
options.json = request.bodyParameters();
|
|
55
53
|
|
|
56
|
-
return
|
|
54
|
+
return import('ky').then((ky) => {
|
|
55
|
+
return ky.default(url, options)
|
|
57
56
|
.json()
|
|
58
57
|
.then((response)=> {
|
|
59
58
|
return new Promise( (resolve) => {
|
|
@@ -62,17 +61,23 @@ class ApiClient {
|
|
|
62
61
|
});
|
|
63
62
|
})
|
|
64
63
|
.catch((error) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
return error.response.text().then((body) => {
|
|
65
|
+
if (error instanceof ky.HTTPError) {
|
|
66
|
+
error = new api_errors.ResponseError(
|
|
67
|
+
request,
|
|
68
|
+
error.response.status,
|
|
69
|
+
body
|
|
70
|
+
);
|
|
71
|
+
} else if (error instanceof ky.TimeoutError) {
|
|
72
|
+
error = new api_errors.TimeoutError(request, error);
|
|
73
|
+
}
|
|
74
|
+
if (callback) {
|
|
75
|
+
return callback(error);
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
})
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
_getRegionalBaseUri(region) {
|
package/lib/errors/index.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ export module "recombee-api-client" {
|
|
|
257
257
|
): string
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
type Response = Item | PropertyInfo | UpdateMoreItemsResponse | DeleteMoreItemsResponse | Series | SeriesItem |
|
|
260
|
+
type Response = Item | PropertyInfo | UpdateMoreItemsResponse | DeleteMoreItemsResponse | Series | SeriesItem | User | DetailView | Purchase | Rating | CartAddition | Bookmark | ViewPortion | RecommendationResponse | SearchResponse | SearchSynonym | ListSearchSynonymsResponse | ListSegmentationsResponse | Segmentation;
|
|
261
261
|
|
|
262
262
|
export type Item = {
|
|
263
263
|
itemId: string;
|
|
@@ -265,8 +265,8 @@ export module "recombee-api-client" {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
export type PropertyInfo = {
|
|
268
|
-
name
|
|
269
|
-
type
|
|
268
|
+
name: string;
|
|
269
|
+
type: string;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
export type UpdateMoreItemsResponse = {
|
|
@@ -290,16 +290,6 @@ export module "recombee-api-client" {
|
|
|
290
290
|
cascadeCreate?: boolean;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
export type Group = {
|
|
294
|
-
groupId: string;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export type GroupItem = {
|
|
298
|
-
itemType: string;
|
|
299
|
-
itemId: string;
|
|
300
|
-
cascadeCreate?: boolean;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
293
|
export type User = {
|
|
304
294
|
userId: string;
|
|
305
295
|
values?: { [key: string]: unknown };
|
|
@@ -519,7 +509,7 @@ export module "recombee-api-client" {
|
|
|
519
509
|
}
|
|
520
510
|
|
|
521
511
|
/**
|
|
522
|
-
* Adding an item property is
|
|
512
|
+
* Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.
|
|
523
513
|
*/
|
|
524
514
|
export class AddItemProperty extends requests.Request {
|
|
525
515
|
/**
|
|
@@ -674,15 +664,22 @@ export module "recombee-api-client" {
|
|
|
674
664
|
export class AddSeries extends requests.Request {
|
|
675
665
|
/**
|
|
676
666
|
* @param seriesId - ID of the series to be created.
|
|
667
|
+
* @param optional - Optional parameters given as an object.
|
|
677
668
|
*/
|
|
678
669
|
constructor(
|
|
679
670
|
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
|
+
}
|
|
680
675
|
);
|
|
681
676
|
|
|
682
677
|
seriesId: string;
|
|
678
|
+
cascadeCreate?: boolean;
|
|
683
679
|
protected __response_type: string;
|
|
684
680
|
|
|
685
681
|
bodyParameters(): {
|
|
682
|
+
cascadeCreate?: boolean;
|
|
686
683
|
};
|
|
687
684
|
|
|
688
685
|
queryParameters(): {
|
|
@@ -696,15 +693,22 @@ export module "recombee-api-client" {
|
|
|
696
693
|
export class DeleteSeries extends requests.Request {
|
|
697
694
|
/**
|
|
698
695
|
* @param seriesId - ID of the series to be deleted.
|
|
696
|
+
* @param optional - Optional parameters given as an object.
|
|
699
697
|
*/
|
|
700
698
|
constructor(
|
|
701
699
|
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
|
+
}
|
|
702
704
|
);
|
|
703
705
|
|
|
704
706
|
seriesId: string;
|
|
707
|
+
cascadeDelete?: boolean;
|
|
705
708
|
protected __response_type: string;
|
|
706
709
|
|
|
707
710
|
bodyParameters(): {
|
|
711
|
+
cascadeDelete?: boolean;
|
|
708
712
|
};
|
|
709
713
|
|
|
710
714
|
queryParameters(): {
|
|
@@ -768,7 +772,7 @@ export module "recombee-api-client" {
|
|
|
768
772
|
itemId: string,
|
|
769
773
|
time: number,
|
|
770
774
|
optional?: {
|
|
771
|
-
/** 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`.
|
|
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. */
|
|
772
776
|
cascadeCreate?: boolean;
|
|
773
777
|
}
|
|
774
778
|
);
|
|
@@ -799,176 +803,24 @@ export module "recombee-api-client" {
|
|
|
799
803
|
* @param seriesId - ID of the series from which a series item is to be removed.
|
|
800
804
|
* @param itemType - Type of the item to be removed.
|
|
801
805
|
* @param itemId - ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`.
|
|
802
|
-
* @param time - Time index of the item to be removed.
|
|
803
806
|
*/
|
|
804
807
|
constructor(
|
|
805
808
|
seriesId: string,
|
|
806
809
|
itemType: string,
|
|
807
810
|
itemId: string,
|
|
808
|
-
time: number,
|
|
809
811
|
);
|
|
810
812
|
|
|
811
813
|
seriesId: string;
|
|
812
814
|
itemType: string;
|
|
813
815
|
itemId: string;
|
|
814
|
-
time: number;
|
|
815
|
-
protected __response_type: string;
|
|
816
|
-
|
|
817
|
-
bodyParameters(): {
|
|
818
|
-
};
|
|
819
|
-
|
|
820
|
-
queryParameters(): {
|
|
821
|
-
itemType: string;
|
|
822
|
-
itemId: string;
|
|
823
|
-
time: number;
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/**
|
|
828
|
-
* Creates a new group in the database.
|
|
829
|
-
*/
|
|
830
|
-
export class AddGroup extends requests.Request {
|
|
831
|
-
/**
|
|
832
|
-
* @param groupId - ID of the group to be created.
|
|
833
|
-
*/
|
|
834
|
-
constructor(
|
|
835
|
-
groupId: string,
|
|
836
|
-
);
|
|
837
|
-
|
|
838
|
-
groupId: string;
|
|
839
|
-
protected __response_type: string;
|
|
840
|
-
|
|
841
|
-
bodyParameters(): {
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
queryParameters(): {
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* Deletes the group of the given `groupId` from the database.
|
|
850
|
-
* Deleting a group will only delete the assignment of items to it, not the items themselves!
|
|
851
|
-
*/
|
|
852
|
-
export class DeleteGroup extends requests.Request {
|
|
853
|
-
/**
|
|
854
|
-
* @param groupId - ID of the group to be deleted.
|
|
855
|
-
*/
|
|
856
|
-
constructor(
|
|
857
|
-
groupId: string,
|
|
858
|
-
);
|
|
859
|
-
|
|
860
|
-
groupId: string;
|
|
861
|
-
protected __response_type: string;
|
|
862
|
-
|
|
863
|
-
bodyParameters(): {
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
queryParameters(): {
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Gets the list of all the groups currently present in the database.
|
|
872
|
-
*/
|
|
873
|
-
export class ListGroups extends requests.Request {
|
|
874
|
-
/**
|
|
875
|
-
|
|
876
|
-
*/
|
|
877
|
-
constructor(
|
|
878
|
-
);
|
|
879
|
-
|
|
880
|
-
protected __response_type: Group[];
|
|
881
|
-
|
|
882
|
-
bodyParameters(): {
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
queryParameters(): {
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* List all the items present in the given group.
|
|
891
|
-
*/
|
|
892
|
-
export class ListGroupItems extends requests.Request {
|
|
893
|
-
/**
|
|
894
|
-
* @param groupId - ID of the group whose items are to be listed.
|
|
895
|
-
*/
|
|
896
|
-
constructor(
|
|
897
|
-
groupId: string,
|
|
898
|
-
);
|
|
899
|
-
|
|
900
|
-
groupId: string;
|
|
901
|
-
protected __response_type: GroupItem[];
|
|
902
|
-
|
|
903
|
-
bodyParameters(): {
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
queryParameters(): {
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
/**
|
|
911
|
-
* Inserts an existing item/group into a group of the given `groupId`.
|
|
912
|
-
*/
|
|
913
|
-
export class InsertToGroup extends requests.Request {
|
|
914
|
-
/**
|
|
915
|
-
* @param groupId - ID of the group to be inserted into.
|
|
916
|
-
* @param itemType - `item` iff the regular item from the catalog is to be inserted, `group` iff group is inserted as the item.
|
|
917
|
-
* @param itemId - ID of the item iff `itemType` is `item`. ID of the group iff `itemType` is `group`.
|
|
918
|
-
* @param optional - Optional parameters given as an object.
|
|
919
|
-
*/
|
|
920
|
-
constructor(
|
|
921
|
-
groupId: string,
|
|
922
|
-
itemType: string,
|
|
923
|
-
itemId: string,
|
|
924
|
-
optional?: {
|
|
925
|
-
/** Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `groupId` and the `groupId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. Either items or group may be created if not present in the database. */
|
|
926
|
-
cascadeCreate?: boolean;
|
|
927
|
-
}
|
|
928
|
-
);
|
|
929
|
-
|
|
930
|
-
groupId: string;
|
|
931
|
-
itemType: string;
|
|
932
|
-
itemId: string;
|
|
933
|
-
cascadeCreate?: boolean;
|
|
934
816
|
protected __response_type: string;
|
|
935
817
|
|
|
936
818
|
bodyParameters(): {
|
|
937
819
|
itemType: string;
|
|
938
820
|
itemId: string;
|
|
939
|
-
cascadeCreate?: boolean;
|
|
940
|
-
};
|
|
941
|
-
|
|
942
|
-
queryParameters(): {
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* Removes an existing group item from the group.
|
|
948
|
-
*/
|
|
949
|
-
export class RemoveFromGroup extends requests.Request {
|
|
950
|
-
/**
|
|
951
|
-
* @param groupId - ID of the group from which a group item is to be removed.
|
|
952
|
-
* @param itemType - Type of the item to be removed.
|
|
953
|
-
* @param itemId - ID of the item iff `itemType` is `item`. ID of the group iff `itemType` is `group`.
|
|
954
|
-
*/
|
|
955
|
-
constructor(
|
|
956
|
-
groupId: string,
|
|
957
|
-
itemType: string,
|
|
958
|
-
itemId: string,
|
|
959
|
-
);
|
|
960
|
-
|
|
961
|
-
groupId: string;
|
|
962
|
-
itemType: string;
|
|
963
|
-
itemId: string;
|
|
964
|
-
protected __response_type: string;
|
|
965
|
-
|
|
966
|
-
bodyParameters(): {
|
|
967
821
|
};
|
|
968
822
|
|
|
969
823
|
queryParameters(): {
|
|
970
|
-
itemType: string;
|
|
971
|
-
itemId: string;
|
|
972
824
|
};
|
|
973
825
|
}
|
|
974
826
|
|
|
@@ -1110,7 +962,7 @@ export module "recombee-api-client" {
|
|
|
1110
962
|
}
|
|
1111
963
|
|
|
1112
964
|
/**
|
|
1113
|
-
* Adding a user property is
|
|
965
|
+
* Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
|
|
1114
966
|
*/
|
|
1115
967
|
export class AddUserProperty extends requests.Request {
|
|
1116
968
|
/**
|
|
@@ -2337,13 +2189,13 @@ export module "recombee-api-client" {
|
|
|
2337
2189
|
}
|
|
2338
2190
|
|
|
2339
2191
|
/**
|
|
2340
|
-
* 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.
|
|
2341
2193
|
* Based on the used Segmentation, this endpoint can be used for example for:
|
|
2342
2194
|
* - Recommending the top categories for the user
|
|
2343
2195
|
* - Recommending the top genres for the user
|
|
2344
2196
|
* - Recommending the top brands for the user
|
|
2345
2197
|
* - Recommending the top artists for the user
|
|
2346
|
-
* 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.
|
|
2347
2199
|
* The returned segments are sorted by relevance (first segment being the most relevant).
|
|
2348
2200
|
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
2349
2201
|
*/
|
|
@@ -2401,13 +2253,13 @@ export module "recombee-api-client" {
|
|
|
2401
2253
|
}
|
|
2402
2254
|
|
|
2403
2255
|
/**
|
|
2404
|
-
* 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.
|
|
2405
2257
|
* Based on the used Segmentation, this endpoint can be used for example for:
|
|
2406
2258
|
* - Recommending the related categories
|
|
2407
2259
|
* - Recommending the related genres
|
|
2408
2260
|
* - Recommending the related brands
|
|
2409
2261
|
* - Recommending the related artists
|
|
2410
|
-
* 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.
|
|
2411
2263
|
* The returned segments are sorted by relevance (first segment being the most relevant).
|
|
2412
2264
|
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
2413
2265
|
*/
|
|
@@ -2481,12 +2333,12 @@ export module "recombee-api-client" {
|
|
|
2481
2333
|
}
|
|
2482
2334
|
|
|
2483
2335
|
/**
|
|
2484
|
-
* 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.
|
|
2485
2337
|
* Based on the used Segmentations, this endpoint can be used for example for:
|
|
2486
2338
|
* - Recommending the related brands to particular brand
|
|
2487
2339
|
* - Recommending the related brands to particular category
|
|
2488
2340
|
* - Recommending the related artists to a particular genre (assuming songs are the Items)
|
|
2489
|
-
* 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.
|
|
2490
2342
|
* The returned segments are sorted by relevance (first segment being the most relevant).
|
|
2491
2343
|
* It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
2492
2344
|
*/
|
|
@@ -2560,6 +2412,106 @@ export module "recombee-api-client" {
|
|
|
2560
2412
|
};
|
|
2561
2413
|
}
|
|
2562
2414
|
|
|
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
|
+
|
|
2563
2515
|
/**
|
|
2564
2516
|
* 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).
|
|
2565
2517
|
* All the string and set item properties are indexed by the search engine.
|
|
@@ -3209,4 +3161,4 @@ export module "recombee-api-client" {
|
|
|
3209
3161
|
};
|
|
3210
3162
|
}
|
|
3211
3163
|
}
|
|
3212
|
-
}
|
|
3164
|
+
}
|
|
@@ -30,7 +30,7 @@ class AddBookmark extends rqs.Request {
|
|
|
30
30
|
* - Description: A dictionary of additional data for the interaction.
|
|
31
31
|
*/
|
|
32
32
|
constructor(userId, itemId, optional) {
|
|
33
|
-
super('POST', '/bookmarks/',
|
|
33
|
+
super('POST', '/bookmarks/', 3000, false);
|
|
34
34
|
this.userId = userId;
|
|
35
35
|
this.itemId = itemId;
|
|
36
36
|
optional = optional || {};
|
|
@@ -36,7 +36,7 @@ class AddCartAddition extends rqs.Request {
|
|
|
36
36
|
* - Description: A dictionary of additional data for the interaction.
|
|
37
37
|
*/
|
|
38
38
|
constructor(userId, itemId, optional) {
|
|
39
|
-
super('POST', '/cartadditions/',
|
|
39
|
+
super('POST', '/cartadditions/', 3000, false);
|
|
40
40
|
this.userId = userId;
|
|
41
41
|
this.itemId = itemId;
|
|
42
42
|
optional = optional || {};
|
|
@@ -33,7 +33,7 @@ class AddDetailView extends rqs.Request {
|
|
|
33
33
|
* - Description: A dictionary of additional data for the interaction.
|
|
34
34
|
*/
|
|
35
35
|
constructor(userId, itemId, optional) {
|
|
36
|
-
super('POST', '/detailviews/',
|
|
36
|
+
super('POST', '/detailviews/', 3000, false);
|
|
37
37
|
this.userId = userId;
|
|
38
38
|
this.itemId = itemId;
|
|
39
39
|
optional = optional || {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const rqs = require("./request");
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Adding an item property is
|
|
9
|
+
* Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types.
|
|
10
10
|
*/
|
|
11
11
|
class AddItemProperty extends rqs.Request {
|
|
12
12
|
|
package/lib/requests/add-item.js
CHANGED
|
@@ -39,7 +39,7 @@ class AddPurchase extends rqs.Request {
|
|
|
39
39
|
* - Description: A dictionary of additional data for the interaction.
|
|
40
40
|
*/
|
|
41
41
|
constructor(userId, itemId, optional) {
|
|
42
|
-
super('POST', '/purchases/',
|
|
42
|
+
super('POST', '/purchases/', 3000, false);
|
|
43
43
|
this.userId = userId;
|
|
44
44
|
this.itemId = itemId;
|
|
45
45
|
optional = optional || {};
|
|
@@ -31,7 +31,7 @@ class AddRating extends rqs.Request {
|
|
|
31
31
|
* - Description: A dictionary of additional data for the interaction.
|
|
32
32
|
*/
|
|
33
33
|
constructor(userId, itemId, rating, optional) {
|
|
34
|
-
super('POST', '/ratings/',
|
|
34
|
+
super('POST', '/ratings/', 3000, false);
|
|
35
35
|
this.userId = userId;
|
|
36
36
|
this.itemId = itemId;
|
|
37
37
|
this.rating = rating;
|
|
@@ -13,10 +13,17 @@ class AddSeries extends rqs.Request {
|
|
|
13
13
|
/**
|
|
14
14
|
* Construct the request
|
|
15
15
|
* @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`.
|
|
16
21
|
*/
|
|
17
|
-
constructor(seriesId) {
|
|
18
|
-
super('PUT', `/series/${seriesId}`,
|
|
22
|
+
constructor(seriesId, optional) {
|
|
23
|
+
super('PUT', `/series/${seriesId}`, 3000, false);
|
|
19
24
|
this.seriesId = seriesId;
|
|
25
|
+
optional = optional || {};
|
|
26
|
+
this.cascadeCreate = optional.cascadeCreate;
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
@@ -26,6 +33,9 @@ class AddSeries extends rqs.Request {
|
|
|
26
33
|
bodyParameters() {
|
|
27
34
|
let params = {};
|
|
28
35
|
|
|
36
|
+
if(this.cascadeCreate !== undefined)
|
|
37
|
+
params.cascadeCreate = this.cascadeCreate;
|
|
38
|
+
|
|
29
39
|
return params;
|
|
30
40
|
}
|
|
31
41
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const rqs = require("./request");
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Adding a user property is
|
|
9
|
+
* Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
|
|
10
10
|
*/
|
|
11
11
|
class AddUserProperty extends rqs.Request {
|
|
12
12
|
|
package/lib/requests/add-user.js
CHANGED
|
@@ -21,7 +21,7 @@ class DeleteBookmark extends rqs.Request {
|
|
|
21
21
|
* - Description: Unix timestamp of the bookmark. If the `timestamp` is omitted, then all the bookmarks with the given `userId` and `itemId` are deleted.
|
|
22
22
|
*/
|
|
23
23
|
constructor(userId, itemId, optional) {
|
|
24
|
-
super('DELETE', '/bookmarks/',
|
|
24
|
+
super('DELETE', '/bookmarks/', 3000, false);
|
|
25
25
|
this.userId = userId;
|
|
26
26
|
this.itemId = itemId;
|
|
27
27
|
optional = optional || {};
|
|
@@ -21,7 +21,7 @@ class DeleteCartAddition extends rqs.Request {
|
|
|
21
21
|
* - Description: Unix timestamp of the cart addition. If the `timestamp` is omitted, then all the cart additions with the given `userId` and `itemId` are deleted.
|
|
22
22
|
*/
|
|
23
23
|
constructor(userId, itemId, optional) {
|
|
24
|
-
super('DELETE', '/cartadditions/',
|
|
24
|
+
super('DELETE', '/cartadditions/', 3000, false);
|
|
25
25
|
this.userId = userId;
|
|
26
26
|
this.itemId = itemId;
|
|
27
27
|
optional = optional || {};
|