recombee_api_client 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -3
- data/lib/recombee_api_client.rb +1 -1
- data/lib/recombee_api_client/api/recommend_items_to_item.rb +12 -5
- data/lib/recombee_api_client/api/recommend_items_to_user.rb +12 -5
- data/lib/recombee_api_client/api/recommend_next_items.rb +69 -0
- data/lib/recombee_api_client/api/recommend_users_to_item.rb +4 -2
- data/lib/recombee_api_client/api/recommend_users_to_user.rb +5 -3
- data/lib/recombee_api_client/api/search_items.rb +11 -4
- data/lib/recombee_api_client/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c24717b90f3a557ec2ceda5bf24f0c62f1ae80384b0a993c7545c156b8586ddd
|
4
|
+
data.tar.gz: d1a88f7d65d7dc7456068975263d435d06059838d9e8c4a1deedf9cbce42e8c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b33bd56d774de4240d04decbc4752b7c506062b26519b1d9e5afb335a61603bd2ba6723faeea545fe773cd659f54fb72490bafe66a112b6b31438eb7d2b0f6f
|
7
|
+
data.tar.gz: 1ea09e4189c88f8aa13f2e35ba36c1792da8877ae40ee1ca787f2f414ebc1da149f3557c0f26c09575106b25ec8019692d4b83e1ae1de88dce22574bdab8051c
|
data/README.md
CHANGED
@@ -55,8 +55,13 @@ begin
|
|
55
55
|
client.send(Batch.new(purchases))
|
56
56
|
|
57
57
|
# Get recommendations for user 'user-25'
|
58
|
-
|
59
|
-
puts "Recommended items for user-25: #{
|
58
|
+
response = client.send(RecommendItemsToUser.new('user-25', 5))
|
59
|
+
puts "Recommended items for user-25: #{response}"
|
60
|
+
|
61
|
+
# User scrolled down - get next 3 recommended items
|
62
|
+
response = client.send(RecommendNextItems.new(response['recommId'], 3))
|
63
|
+
puts "Next recommended items for user-25: #{response}"
|
64
|
+
|
60
65
|
rescue APIError => e
|
61
66
|
puts e
|
62
67
|
# Use fallback
|
@@ -146,7 +151,7 @@ recommended = client.send(
|
|
146
151
|
|
147
152
|
# Perform personalized full-text search with a user's search query (e.g. 'computers').
|
148
153
|
matches = client.send(
|
149
|
-
SearchItems.new('user-42', 'computers', 5)
|
154
|
+
SearchItems.new('user-42', 'computers', 5, {:scenario => 'search_top'})
|
150
155
|
)
|
151
156
|
puts "Matched items: #{matches}"
|
152
157
|
```
|
data/lib/recombee_api_client.rb
CHANGED
@@ -18,7 +18,7 @@ module RecombeeApiClient
|
|
18
18
|
include HTTParty
|
19
19
|
|
20
20
|
BATCH_MAX_SIZE = 10000
|
21
|
-
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.
|
21
|
+
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/3.1.0'}
|
22
22
|
|
23
23
|
##
|
24
24
|
# - +account+ -> Name of your account at Recombee
|
@@ -9,9 +9,14 @@ module RecombeeApiClient
|
|
9
9
|
##
|
10
10
|
#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.
|
11
11
|
#
|
12
|
-
#
|
12
|
+
#The returned items are sorted by relevance (first item being the most relevant).
|
13
|
+
#
|
14
|
+
#Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
13
15
|
#
|
14
|
-
|
16
|
+
#- 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).
|
17
|
+
#- 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).
|
18
|
+
#
|
19
|
+
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
15
20
|
#
|
16
21
|
class RecommendItemsToItem < ApiRequest
|
17
22
|
attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
|
@@ -75,7 +80,8 @@ module RecombeeApiClient
|
|
75
80
|
# "url": "myshop.com/mixer-42"
|
76
81
|
# }
|
77
82
|
# }
|
78
|
-
# ]
|
83
|
+
# ],
|
84
|
+
# "numberNextRecommsCalls": 0
|
79
85
|
# }
|
80
86
|
#```
|
81
87
|
#
|
@@ -101,7 +107,8 @@ module RecombeeApiClient
|
|
101
107
|
# "price": 39
|
102
108
|
# }
|
103
109
|
# }
|
104
|
-
# ]
|
110
|
+
# ],
|
111
|
+
# "numberNextRecommsCalls": 0
|
105
112
|
# }
|
106
113
|
#```
|
107
114
|
#
|
@@ -124,7 +131,7 @@ module RecombeeApiClient
|
|
124
131
|
#
|
125
132
|
# - +diversity+ -> **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.
|
126
133
|
#
|
127
|
-
# - +minRelevance+ -> **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
|
134
|
+
# - +minRelevance+ -> **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.
|
128
135
|
#
|
129
136
|
# - +rotationRate+ -> **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.
|
130
137
|
#
|
@@ -11,9 +11,14 @@ module RecombeeApiClient
|
|
11
11
|
#
|
12
12
|
#The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email.
|
13
13
|
#
|
14
|
-
#
|
14
|
+
#The returned items are sorted by relevance (first item being the most relevant).
|
15
|
+
#
|
16
|
+
#Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
15
17
|
#
|
16
|
-
|
18
|
+
#- 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).
|
19
|
+
#- 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).
|
20
|
+
#
|
21
|
+
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
17
22
|
#
|
18
23
|
class RecommendItemsToUser < ApiRequest
|
19
24
|
attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
|
@@ -61,7 +66,8 @@ module RecombeeApiClient
|
|
61
66
|
# "url": "myshop.com/mixer-42"
|
62
67
|
# }
|
63
68
|
# }
|
64
|
-
# ]
|
69
|
+
# ],
|
70
|
+
# "numberNextRecommsCalls": 0
|
65
71
|
# }
|
66
72
|
#```
|
67
73
|
#
|
@@ -87,7 +93,8 @@ module RecombeeApiClient
|
|
87
93
|
# "price": 39
|
88
94
|
# }
|
89
95
|
# }
|
90
|
-
# ]
|
96
|
+
# ],
|
97
|
+
# "numberNextRecommsCalls": 0
|
91
98
|
# }
|
92
99
|
#```
|
93
100
|
#
|
@@ -108,7 +115,7 @@ module RecombeeApiClient
|
|
108
115
|
#
|
109
116
|
# - +diversity+ -> **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.
|
110
117
|
#
|
111
|
-
# - +minRelevance+ -> **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
|
118
|
+
# - +minRelevance+ -> **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.
|
112
119
|
#
|
113
120
|
# - +rotationRate+ -> **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.1`.
|
114
121
|
#
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# This file is auto-generated, do not edit
|
3
|
+
#
|
4
|
+
|
5
|
+
module RecombeeApiClient
|
6
|
+
require_relative 'request'
|
7
|
+
require_relative '../errors'
|
8
|
+
|
9
|
+
##
|
10
|
+
#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.
|
11
|
+
#
|
12
|
+
#It accepts `recommId` of a base recommendation request (e.g. request from the first page) and number of items that shall be returned (`count`).
|
13
|
+
#The base request can be one of:
|
14
|
+
# - [Recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item)
|
15
|
+
# - [Recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user)
|
16
|
+
# - [Search items](https://docs.recombee.com/api.html#search-items)
|
17
|
+
#
|
18
|
+
#All the other parameters are inherited from the base request.
|
19
|
+
#
|
20
|
+
#*Recommend next items* can be called many times for a single `recommId` and each call returns different (previously not recommended) items.
|
21
|
+
#The number of *Recommend next items* calls performed so far is returned in the `numberNextRecommsCalls` field.
|
22
|
+
#
|
23
|
+
#*Recommend next items* can be requested up to 30 minutes after the base request or a previous *Recommend next items* call.
|
24
|
+
#
|
25
|
+
#For billing purposes, each call to *Recommend next items* is counted as a separate recommendation request.
|
26
|
+
#
|
27
|
+
class RecommendNextItems < ApiRequest
|
28
|
+
attr_reader :recomm_id, :count
|
29
|
+
attr_accessor :timeout
|
30
|
+
attr_accessor :ensure_https
|
31
|
+
|
32
|
+
##
|
33
|
+
# * *Required arguments*
|
34
|
+
# - +recomm_id+ -> ID of the base recommendation request for which next recommendations should be returned
|
35
|
+
# - +count+ -> Number of items to be recommended
|
36
|
+
#
|
37
|
+
#
|
38
|
+
def initialize(recomm_id, count)
|
39
|
+
@recomm_id = recomm_id
|
40
|
+
@count = count
|
41
|
+
@timeout = 3000
|
42
|
+
@ensure_https = false
|
43
|
+
end
|
44
|
+
|
45
|
+
# HTTP method
|
46
|
+
def method
|
47
|
+
:post
|
48
|
+
end
|
49
|
+
|
50
|
+
# Values of body parameters as a Hash
|
51
|
+
def body_parameters
|
52
|
+
p = Hash.new
|
53
|
+
p['count'] = @count
|
54
|
+
p
|
55
|
+
end
|
56
|
+
|
57
|
+
# Values of query parameters as a Hash.
|
58
|
+
# name of parameter => value of the parameter
|
59
|
+
def query_parameters
|
60
|
+
params = {}
|
61
|
+
params
|
62
|
+
end
|
63
|
+
|
64
|
+
# Relative path to the endpoint
|
65
|
+
def path
|
66
|
+
"/{databaseId}/recomms/next/items/#{@recomm_id}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -53,7 +53,8 @@ module RecombeeApiClient
|
|
53
53
|
# "sex": "M"
|
54
54
|
# }
|
55
55
|
# }
|
56
|
-
# ]
|
56
|
+
# ],
|
57
|
+
# "numberNextRecommsCalls": 0
|
57
58
|
# }
|
58
59
|
#```
|
59
60
|
#
|
@@ -77,7 +78,8 @@ module RecombeeApiClient
|
|
77
78
|
# "country": "CAN"
|
78
79
|
# }
|
79
80
|
# }
|
80
|
-
# ]
|
81
|
+
# ],
|
82
|
+
# "numberNextRecommsCalls": 0
|
81
83
|
# }
|
82
84
|
#```
|
83
85
|
#
|
@@ -53,8 +53,9 @@ module RecombeeApiClient
|
|
53
53
|
# "sex": "M"
|
54
54
|
# }
|
55
55
|
# }
|
56
|
-
# ]
|
57
|
-
#
|
56
|
+
# ],
|
57
|
+
# "numberNextRecommsCalls": 0
|
58
|
+
# }
|
58
59
|
#```
|
59
60
|
#
|
60
61
|
# - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
@@ -77,7 +78,8 @@ module RecombeeApiClient
|
|
77
78
|
# "country": "CAN"
|
78
79
|
# }
|
79
80
|
# }
|
80
|
-
# ]
|
81
|
+
# ],
|
82
|
+
# "numberNextRecommsCalls": 0
|
81
83
|
# }
|
82
84
|
#```
|
83
85
|
#
|
@@ -13,9 +13,14 @@ module RecombeeApiClient
|
|
13
13
|
#
|
14
14
|
#This endpoint should be used in a search box at your website/app. It can be called multiple times as the user is typing the query in order to get the most viable suggestions based on current state of the query, or once after submitting the whole query.
|
15
15
|
#
|
16
|
-
#
|
16
|
+
#The returned items are sorted by relevance (first item being the most relevant).
|
17
|
+
#
|
18
|
+
#Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
17
19
|
#
|
18
|
-
|
20
|
+
#- Let Recombee know that this search was successful (e.g. user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui.html#reported-metrics).
|
21
|
+
#- Get subsequent search results when the user scrolls down or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api.html#recommend-next-items).
|
22
|
+
#
|
23
|
+
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
19
24
|
#
|
20
25
|
class SearchItems < ApiRequest
|
21
26
|
attr_reader :user_id, :search_query, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :expert_settings, :return_ab_group
|
@@ -62,7 +67,8 @@ module RecombeeApiClient
|
|
62
67
|
# "url": "myshop.com/mixer-42"
|
63
68
|
# }
|
64
69
|
# }
|
65
|
-
# ]
|
70
|
+
# ],
|
71
|
+
# "numberNextRecommsCalls": 0
|
66
72
|
# }
|
67
73
|
#```
|
68
74
|
#
|
@@ -88,7 +94,8 @@ module RecombeeApiClient
|
|
88
94
|
# "price": 39
|
89
95
|
# }
|
90
96
|
# }
|
91
|
-
# ]
|
97
|
+
# ],
|
98
|
+
# "numberNextRecommsCalls": 0
|
92
99
|
# }
|
93
100
|
#```
|
94
101
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recombee_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Fiedler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/recombee_api_client/api/merge_users.rb
|
148
148
|
- lib/recombee_api_client/api/recommend_items_to_item.rb
|
149
149
|
- lib/recombee_api_client/api/recommend_items_to_user.rb
|
150
|
+
- lib/recombee_api_client/api/recommend_next_items.rb
|
150
151
|
- lib/recombee_api_client/api/recommend_users_to_item.rb
|
151
152
|
- lib/recombee_api_client/api/recommend_users_to_user.rb
|
152
153
|
- lib/recombee_api_client/api/remove_from_group.rb
|
@@ -181,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
182
|
- !ruby/object:Gem::Version
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.6.11
|
185
|
+
rubygems_version: 3.1.2
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Client for Recombee recommendation API
|