1. 个性化推荐
1.1. 接口描述
适用于给用户提供Feed流形态的个性化推荐。
1.2. 请求方法
1.2.1. Http Method
POST(application/json)
1.2.2. Http 返回格式
JSON
1.2.3. URL
http://{$host_name}:8201/api/rec/personal
注: host_name 为神策推荐在线服务服务器地址
1.2.4. Http 请求参数说明
参数 | 类型 | 是否必须 | 说明 | 示例 |
---|
section_id | String | 必须 | 栏位标识 | 如: home_feed |
distinct_id | String | 必须 | 用户唯一标识 | 如: 100ff36a832edacd |
log_id | String | 可选 | 请求唯一标识 | 如: 1747acc892ebcda |
exp_id | String | 可选 | 请求方实验分流标识 | 默认为 sensors_rec |
limit | String | 可选 | 请求结果的个数 | 默认为 10 |
need_top_item | String | 可选 | 是否需要返回置顶数据 | value: (true or false) 默认为 空字符串, 传 "true" 为需要置顶数据 |
1.2.5. Http 返回结果说明
字段 |
| 类型 | 描述 | 示例 |
---|
code |
| Int | 返回状态码 | 如: 200 |
msg |
| String | 提示信息 | 默认为 "" |
log_id |
| String | 请求唯一标识(来自请求) |
|
exp_id |
| String | 请求方实验分流标识(来自请求) |
|
strategy_id |
| String | 策略实验分流标识(物品ID) | 默认为 baseline |
data |
| List | 推荐结果 | 如:[{'item_id':'1', 'item_type': 'video', 'retrieve_id':'hot', ...}, ...] |
- | item_id | String | 推荐结果唯一标识 | 如: 220276 |
- | item_type | String | 推荐结果类型 | 如: video |
- | retrieve_id | String | 推荐结果来源标识 | 如: hot (热门) |
- | weight | Int | 推荐结果加权系数 | 如: 1,取值范围1-5 |
1.3. 请求示例
1.3.1. CURL调用示例
curl -H "Content-Type: application/json" -X POST -d \
'{"section_id":"home_feed", "log_id":"WXCA059A3D84AF05C6","distinct_id":"100ff36a832edacd","limit":"3","exp_id":"sensors_rec"}' \
http://rec01:8201/api/rec/personal
1.3.2. 成功返回示例
"code": 200,
"data": [
{"item_id": "220276",
"item_type": "video",
"retrieve_id": "hot",
"weight": 1},
{"item_id": "220741",
"item_type": "video",
"retrieve_id": "hot",
"weight": 1},
{"item_id": "58784",
"item_type": "video",
"retrieve_id": "hot",
"weight": 2}
],
"msg": "",
"strategy_id": "baseline",
"log_id": "WXCA059A3D84AF05C6",
"exp_id": "sensors_rec"
}
1.3.3. 失败返回示例(及说明)
{
"code": 299,
"msg": "",
}
无返回结果 或 返回结果中 code 不为 2xx 则视为请求失败。常见错误码与原因对照如下:
2. 相关推荐
2.1. 接口描述
适用于给用户提供物品的相关推荐。
2.2. 请求方法
2.2.1. Http Method
POST(application/json)
2.2.2. Http 返回格式
JSON
2.2.3. URL
http://{$host_name}:8201/api/rec/relevant
注: host_name 为神策推荐在线服务服务器地址
2.2.4. Http 请求参数说明
参数 | 类型 | 是否必须 | 说明 | 示例 |
---|
section_id | String | 必须 | 栏位标识 | 如: similar_product |
distinct_id | String | 必须 | 用户唯一标识 | 如: 100ff36a832edacd |
item_id | String | 必须 | 相关源物品唯一标识 | 如: '671791' |
item_type | String | 必须 | 相关源物品类型 | 如: 'video' |
log_id | String | 可选 | 请求唯一标识 | 如: 1747acc892ebcda |
exp_id | String | 可选 | 请求方实验分流标识 | 默认为 sensors_rec |
offset | String | 可选 | 请求结果起点 | 默认为 0 |
limit | String | 可选 | 请求结果的个数 | 默认为 10 |
need_top_item | String | 可选 | 是否需要返回置顶数据 | value: (true or false) 默认为 空字符串, 传 "true" 为需要置顶数据 |
注:相关推荐一段时间内结果固定,需请求方利用 offset 与 limit 配合进行翻页,默认最多准备约500个结果。
2.2.5. Http 返回结果说明
字段 |
| 类型 | 描述 | 示例 |
---|
code |
| Int | 返回状态码 | 如: 200 |
msg |
| String | 提示信息 | 默认为 "" |
log_id |
| String | 请求唯一标识(来自请求) |
|
exp_id |
| String | 实验分流标识(来自请求) |
|
strategy_id |
| String | 策略实验分流标识 | 默认为 baseline |
offset |
| Int | 下次请求起始偏移位 |
|
data |
| List | 推荐结果 | 如:[{'item_id':'671785', 'item_type': 'video', 'retrieve_id':'hmf', ...}, ...] |
- | item_id | String | 推荐结果唯一标识(物品ID) | 如: 671785 |
- | item_type | String | 推荐结果类型 | 如: video |
- | retrieve_id | String | 推荐结果来源标识 | 如: hmf |
- | weight | Int | 推荐结果加权系数 | 如: 1,取值范围1-5 |
2.3. 请求示例
2.3.1. CURL调用示例
curl -H "Content-Type: application/json" -X POST -d \
'{"section_id":"similar_product", log_id":"WXCA059A3D84AF05C6","distinct_id":"100ff36a832edacd","item_id":"671791","item_type":"video","limit":"3","offset":"0","exp_id":"sensors_rec"}' \
http://rec01:8201/api/rec/relevant
2.3.2. 成功返回示例
{
"code": 200,
"data": [
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hmf",
"weight": 1},
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hmf",
"weight": 1},
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hmf",
"weight": 1}
],
"msg": "",
"offset": 3,
"strategy_id": "baseline",
"log_id": "WXCA059A3D84AF05C6",
"exp_id": "sensors_rec"
}
3. 热门推荐
3.1. 接口描述
适用于给用户提供热门推荐。
3.2. 请求方法
3.2.1. Http Method
POST(application/json)
3.2.2. Http 返回格式
JSON
3.2.3. URL
http://{$host_name}:8201/api/rec/hot
注: host_name 为神策推荐在线服务服务器地址
3.2.4. Http 请求参数说明
参数 | 类型 | 是否必须 | 说明 | 示例 |
---|
section_id | String | 必须 | 栏位标识 | 如: home_hots |
distinct_id | String | 必须 | 用户唯一标识 | 如: 100ff36a832edacd |
log_id | String | 可选 | 请求唯一标识 | 如: 1747acc892ebcda |
exp_id | String | 可选 | 请求方实验分流标识 | 默认为 sensors_rec |
offset | String | 可选 | 请求结果起点 | 默认为 0 |
limit | String | 可选 | 请求结果的个数 | 默认为 10 |
need_top_item | String | 可选 | 是否需要返回置顶数据 | value: (true or false) 默认为 空字符串, 传 "true" 为需要置顶数据 |
注:热门推荐一段时间内结果固定,需请求方利用 offset 与 limit 配合进行翻页,默认最多准备约1000个结果。
3.2.5. Http 返回结果说明
字段 |
| 类型 | 描述 | 示例 |
---|
code |
| Int | 返回状态码 | 如: 200 |
msg |
| String | 提示信息 | 默认为 "" |
log_id |
| String | 请求唯一标识(来自请求) |
|
exp_id |
| String | 实验分流标识(来自请求) |
|
strategy_id |
| String | 策略实验分流标识 | 默认为 baseline |
offset |
| Int | 下次请求起始偏移位 |
|
data |
| List | 推荐结果 | 如:[{'item_id':'671785', 'item_type': 'video', 'retrieve_id':'hmf', ...}, ...] |
- | item_id | String | 推荐结果唯一标识(物品ID) | 如: 671785 |
- | item_type | String | 推荐结果类型 | 如: video |
- | retrieve_id | String | 推荐结果来源标识 | 如: hot |
3.3. 请求示例
3.3.1. CURL调用示例
curl -H "Content-Type: application/json" -X POST -d \
'{"section_id":"home_hots","category":"all_category","log_id":"WXCA059A3D84AF05C6","distinct_id":"100ff36a832edacd","limit":"3","offset":"0","exp_id":"sensors_rec"}' \
http://rec01:8201/api/rec/hot
3.3.2. 成功返回示例
{
"code": 200,
"data": [
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hot"},
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hot"},
{"item_id": "671785",
"item_type": "video",
"retrieve_id": "hot"}
],
"msg": "",
"offset": 3,
"strategy_id": "baseline",
"log_id": "WXCA059A3D84AF05C6",
"exp_id": "sensors_rec"
}