This interface is used to create clusters, which can be created based on rules or uploaded files.
Path:/openapi/v1/{app_id}/cohorts
Method: POST
Content-type: application/json
Path-parameters : refer to public parameters
Body:
{ "cohort_name": "cohort name", "cohort_type": 4, "description": "cohort description", "dsl_content": {}, "refresh_rule": 1 }
Field meaning description
Field | Type | Description |
|---|---|---|
cohort_name | int | group name |
cohort_type | int | Cluster type, fixed to 4, that is, rule creation, indicating the creation of clusters through dsl_content |
description | string | grouping description information |
dsl_content | object | Grouping rules can be copied and modified after the front-end UI configuration, see Section 7.3 for details |
refresh_rule | int | 1: Manual refresh 2: Daily routine refresh |
Response:
{ "code": 200, "message": "success", "data": { "cohort_id": 6 } }
Field meaning description
Field | Type | Description |
|---|---|---|
cohort_id | int | Create a successful cluster ID |
Bc is the RangersClient created. For its initialization, please refer to the "OpenAPI SDK Instructions". SDKs in various languages provide similar interfaces
Call (Python):
# for example, app_id= 164314 dsl = { "cohort_name": "openapi-creation", "cohort_type": 4, #4 Represents rule creation "description": "", "dsl_content": { "periods": [], "app_ids": [ 164314 ], "content": { "profile_filters": [], "profile_groups": [], "queries": [ [ { "show_label": "event--A--A", "event_name": "any_event", "event_type": "origin", "next_query_label": null, "sequence_first": true, "logic": true, "condition": { "property_operation": ">", "property_values": [ 0 ], "period": { "granularity": "day", "last": { "amount": 7, "unit": "day" }, "type": "last", "timezone": "Asia/Shanghai" } }, "filters": [ { "expression": { "logic": "and", "conditions": [] } } ], "event_indicator": "events" } ] ], "query_type": "$cohort" }, "version": 3 }, "refresh_rule": 1 #1 means manual refresh, 2 means daily refresh } resp = bc.data_finder("/openapi/v1/164314/cohorts", body=dsl) cohort_id = resp.json()["data"]["cohort_id"]
Return result:
{ "code": 200, "message": "success", "data": { "cohort_id": 6 } }
Return result:
{ "code": 200, "message": "success", "data": { "cohort_id": 6 } }
Configure the rules in the cluster configuration page, then open the browser console, and then click "Estimated number of people" to view the dsl_content field of the overview interface. (Note: When using dsl_content, it is best to delete the show_option node as a whole.)