接口地址 请求方式
https://beibei.dataoke.com/api/recommend/sendAction POST

背景说明

由贝贝公司回传用户行为数据,大淘客接收并进行流批一体的数据处理。

技术架构

核心服务

  1. openresty:
  • 基于 NGINX 的可伸缩的 Web 平台。
  1. lua
  • 轻量小巧的脚本语言。
  1. kafka-product
  • 消息队列
  • topic: client_recommend

单条回传数据格式

列名 类型 案例 说明
product_id string 432542 商品ID
user_id string 1343 用户ID
action_time string 1602739498 时间戳(秒)
event string expose 事件名称
location string 首页 页面模块名称
is_wifi string wifi 是否使用wifi
position string 四川-成都 位置(省-市)
app_version string 1.2.1 app的版本号
device string Xiaomi MIX 2S 设备型号
device_id string D23ED830268543269E75C52C25C8416E 设备ID号
sys_version string 13.6 操作系统版本号
ip string 171.88.41.123 客户端ip地址
event_value 1 事件的行为类型

json数据格式

  1. * 通过POST请求回传数据,BODY格式为JSON ARRAY,可以多条或单条回传。
  2. [
  3. {
  4. "product_id":"42421",
  5. "user_id":"432421",
  6. "action_time":"1602739498",
  7. /* expose:曝光, click:点击, collect:收藏, purchase:购买, share:分享, hate:讨厌, digg:点赞:, comment:评论, search:搜索 */
  8. "event":"expose",
  9. /* home:首页, detail:详情页, search:收藏页 (模块页面需产品定义) */
  10. "location":"home",
  11. /* 1:使用wifi, 2:不使用wifi */
  12. "is_wifi":"1",
  13. "position":"四川-成都",
  14. "app_version":"1.2.1",
  15. "device":"Xiaomi MIX 2S",
  16. /* 设备uuid */
  17. "device_id":"D23ED830268543269E75C52C25C8416E",
  18. "sys_version":"13.6",
  19. "ip":"171.88.41.123",
  20. /**
  21. * 正数: 事件的行为类型 1为正向行为,例如点赞成功。
  22. * 0: 为无效行为,例如取消点赞。
  23. * 负数: 为负向行为,例如-1不感兴趣,-2标题夸张,-3价格不符,-4内容质量差
  24. **/
  25. "event_value":"1"
  26. },
  27. {
  28. "product_id":"42422",
  29. "user_id":"432421",
  30. "action_time":"1602739498",
  31. "event":"click",
  32. "location":"detail",
  33. "is_wifi":"1",
  34. "position":"四川-成都",
  35. "app_version":"1.2.1",
  36. "device":"Xiaomi MIX 2S",
  37. "device_id":"D23ED830268543269E75C52C25C8416E",
  38. "sys_version":"13.6",
  39. "ip":"171.88.41.123",
  40. "event_value":"0"
  41. },
  42. {
  43. "product_id":"42421",
  44. "user_id":"432421",
  45. "action_time":"1602739498",
  46. /* expose:曝光, click:点击, collect:收藏, purchase:购买, share:分享, hate:讨厌, digg:点赞:, comment:评论, search:搜索 */
  47. "event":"hate",
  48. /* home:首页, detail:详情页, search:收藏页 (模块页面需产品定义) */
  49. "location":"home",
  50. /* 1:使用wifi, 2:不使用wifi */
  51. "is_wifi":"1",
  52. "position":"四川-成都",
  53. "app_version":"1.2.1",
  54. "device":"Xiaomi MIX 2S",
  55. /* 设备uuid */
  56. "device_id":"D23ED830268543269E75C52C25C8416E",
  57. "sys_version":"13.6",
  58. "ip":"171.88.41.123",
  59. /**
  60. * 正数: 事件的行为类型 1为正向行为,例如点赞成功。
  61. * 0: 为无效行为,例如取消点赞。
  62. * 负数: 为负向行为,例如-1不感兴趣,-2标题夸张,-3价格不符,-4内容质量差
  63. **/
  64. "event_value":"-1"
  65. }
  66. ]

接口返回示例:

  1. * code:0代表成功,code:-1代表失败。
  2. 中间有几个判断:
  3. 1.是否是POST请求
  4. 2.是否json格式
  5. 3.是否写入kafka
  6. 任意一个失败返回是-1
  7. ------------------------------
  8. {
  9. "code":0
  10. }