Ver <= 1.12 版本的分群 API

最后更新于:2018-12-19 14:55:59

1 分群规则描述

规则描述部分是可嵌套的结构,较为复杂,此处单独进行描述。 在 “添加” 分群时,会用到规则描述。

举例说明:

  "content": [
    {
      "type": 0,  // 用户属性类型是0
      "profile_filter": {
        "filter": {
          "conditions": [
            {
              "field": "user.first_visit_channel",
              "function": "equal",
              "params": [
                "今日头条"
              ]
            }
          ]
        }
      }
    },
    {
      "type": 1,    // 做过类型是1
      "event_filter": {
        "event_name": "ViewHomepage",
        "filter": {
          "relation": "",
          "conditions": []
        }
      },
      "min_repeated_times": 5,
      "max_repeated_times": 0,
      "relative_time_range": "",
      "absolute_time_range": [
        "2016-10-17 00:00:00",
        "2016-10-20 00:00:00"
      ],
      "relation": "and"
    },
    {
      "type": 2,  // 行为序列类型是2
      "event_filter_sequence": [
        {
          "event_name": "ContactCustomerService",
          "filter": {
            "conditions": [
              {
                "field": "event.ContactCustomerService.service_type",
                "function": "equal",
                "params": [
                  "电话联系"
                ]
              }
            ]
          }
        },
        {
          "event_name": "ViewFunction",
          "filter": {}
        }
      ],
      "absolute_time_range": [
        "2016-10-17 00:00:00",
        "2016-10-20 00:00:00"
      ],
      "relative_time_range": ""
    }

2 添加一个分群

[POST /segmenter/rule]

  • Request (application/json)
{
  "name": "last_30_days_apply",
  "cname": "last_30_days_apply",
  "status": "new", // 新建分群状态是 new
  "statusClass": "icon-new",
  "type": 0, // 单次分群值为0, 例行分群值为1, 预测分群值为4
  "content": [
    {
      "type": 0,  // 用户属性类型是0
      "profile_filter": {
        "filter": {
          "conditions": [
            {
              "field": "user.first_visit_channel",
              "function": "equal",
              "params": [
                "今日头条"
              ]
            }
          ]
        }
      }
    },
    {
      "type": 1,    // 做过类型是1
      "event_filter": {
        "event_name": "ViewHomepage",
        "filter": {
          "relation": "",
          "conditions": []
        }
      },
      "min_repeated_times": 5,
      "max_repeated_times": 0,
      "relative_time_range": "",
      "absolute_time_range": [
        "2016-10-17 00:00:00",
        "2016-10-20 00:00:00"
      ],
      "relation": "and"
    },
    {
      "type": 2,  // 行为序列类型是2
      "event_filter_sequence": [
        {
          "event_name": "ContactCustomerService",
          "filter": {
            "conditions": [
              {
                "field": "event.ContactCustomerService.service_type",
                "function": "equal",
                "params": [
                  "电话联系"
                ]
              }
            ]
          }
        },
        {
          "event_name": "ViewFunction",
          "filter": {}
        }
      ],
      "absolute_time_range": [
        "2016-10-17 00:00:00",
        "2016-10-20 00:00:00"
      ],
      "relative_time_range": ""
    }
  ]
}
  • Response 200 (application/json)
{
    "id": 1  // 分群id      
}

3 执行一个分群

[POST /segmenter/execute/{segmenterId}]

4 获取一个分群的执行状态

[POST /segmenter/status]

  • Request (application/json)
[
    1 // 分群id
]
  • Response 200 (application/json)
[
  {
    "num_values": 12,
    "id": 10,
    "success_time": "2016-10-20 00:53:24",
    "status": "preparing", // preparing表示运行中,finish表示执行完成,failed表示执行失败
    "last_partition": "2016-10-19 00:00:00"
  }
]

5 删除一个分群

[DELETE /segmenter/rule/{segmenterId}]

6 获取所有分群

[GET /segmenter/rule/all]

  • Response (application/json)
 [
  {
    "num_values": 10,
    "name": "last_30_days_apply",
    "cname": "过去30天申请试用",
    "id": 2,
    "success_time": "2016-10-20 00:53:24",
    "type": 1,
    "content": [
      {
        "type": 0,
        "profile_filter": {
          "filter": {
            "conditions": [
              {
                "field": "user.first_visit_channel",
                "function": "equal",
                "params": [
                  "今日头条"
                ]
              }
            ]
          }
        }
      },
      {
        "type": 1,
        "relation": "and",
        "event_filter": {
          "event_name": "ViewHomepage",
          "filter": {
            "relation": "",
            "conditions": []
          }
        },
        "min_repeated_times": 5,
        "max_repeated_times": 0,
        "absolute_time_range": [],
        "relative_time_range": "30 day"
      },
      {
        "type": 2,
        "event_filter_sequence": [
          {
            "event_name": "ContactCustomerService",
            "filter": {
              "conditions": [
                {
                  "field": "event.ContactCustomerService.service_type",
                  "function": "equal",
                  "params": [
                    "电话联系"
                  ]
                }
              ]
            }
          },
          {
            "event_name": "ViewFunction",
            "filter": {}
          }
        ],
        "absolute_time_range": [],
        "relative_time_range": "0 week"
      }
    ],
    "status": "finish",
    "last_partition": "2016-10-19 00:00:00"
  },
  {
    "num_values": 1015,
    "name": "last_week_full",
    "cname": "过去7天走过完整申请流程",
    "id": 3,
    "success_time": "2016-10-20 00:53:24",
    "type": 1,
    "content": [
      {
        "type": 2,
        "event_filter_sequence": [
          {
            "event_name": "ViewHomepage",
            "filter": {}
          },
          {
            "event_name": "ViewFunction",
            "filter": {}
          },
          {
            "event_name": "ApplyDemo",
            "filter": {}
          }
        ],
        "absolute_time_range": [],
        "relative_time_range": "7 day"
      }
    ],
    "status": "finish",
    "last_partition": "2016-10-19 00:00:00"
  }
]