You need to enable JavaScript to run this app.
最新活动
产品
解决方案
定价
合作与生态
支持与服务
开发者
了解我们
导航

查询API

更新时间:2023.05.29 20:48:39

1.概述

为了更好的跟企业数据产品打通,更好的发挥数据价值,我们通过开放openapi的方式,提供基于本产品进行二次开发的能力,您可以通过调用openapi获取指标数据,以便集成在其他数据产品中。

2.查询分析 OpenAPI 说明(SaaS)

2.1 API 定义

Context-Path: /datafinder
Path:/openapi/v1/analysis
Method: POST
Content-type: application/json
Body:

  • 请求参数均采用查询 DSL 进行描述

  • 数据编码为 UTF-8

Response:
结构说明:

{
    "code": 200, # 返回码,200代表查询返回正确,非200请参考message
    "data": [
        {
            "error_message": null, # 错误消息
            "region_info_map": {}, # 区域查询时区域id映射
            "trace_id": "6bcbc580ab144afd8b8a792349ed9a5a", # 链路追踪标识
            "query_id": "a00:p00:c00:q00", # 子查询标识
            "result_status": "SUCCESS", # 子查询状态
            "execute_time": 0, # 子查询执行时间
            "data_item_list": [ # 子查询返回数据
                {
                    "filter_label": null, # 过滤标签
                    "group_by_key": "__all", # 分组key
                    "data": [ # 指标数据
                        142099,
                        145940,
                        139035,
                        148457,
                        154313
                    ],
                    "sum_value_square": 106673323444, # 指标平方和
                    "composed_item_key": null,
                    "item_key": "a00:p00:c00:q00:f00_0",
                    "show_name": "活跃用户数",
                    "sum": 729844, # 指标求和值
                    "event_params": {},
                    "filter_value": null,
                    "event_name_alias": "",
                    "prefix_key": "active_user",
                    "avg": 145968.8, # 指标平均值
                    "result_type_unit": null,
                    "event_show_name": "应用启动",
                    "event_indicator_params": {},
                    "composed_label": null,
                    "show_label": "active_user",
                    "suffix_key": "__all",
                    "origin_profile_params": {},
                    "result_type": "event_users",
                    "attr_value_name": "",
                    "result_type_label": "活跃用户数",
                    "is_disabled": null,
                    "profile_params": {},
                    "event_label": "active_user",
                    "origin_key": "__all",
                    "event_id": null,
                    "is_compute": null,
                    "name": "active_user, __all",
                    "event_name": "app_launch",
                    "group_by_type": "user_attr"
                }
            ],
            "error_code": null,
            "date_index_list": [ # 数据时间索引值,与数据一一对应
                "20200606",
                "20200607",
                "20200608",
                "20200609",
                "20200610"
            ]
        }
    ],
    "message": "success" # 错误消息
}

2.2 OpenAPI SDK使用样例

bc 为创建的 RangersClient, 其初始化请参考 “OpenAPI SDK 使用说明”, 各语言的 SDK 都提供了类似的接口

调用(Python):

dsl = {
    "version": 3,
    "app_ids": [164314],
    "use_app_cloud_id": True,
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 5,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "content": {
            "query_type": "event",
            "profile_groups_v2": [],
            "profile_filters": [],
            "queries": [
                [
                    {
                        "event_type": "origin",
                        "show_name": "活跃用户数",
                        "event_name": "app_launch",
                        "groups_v2": [],
                        "filters": [],
                        "show_label": "active_user",
                        "event_indicator": "event_users"
                    }
                ]
            ],
            "option": {
                "skip_cache": False
            }
        }
}

# SaaS 逻辑
resp = bc.data_finder("/openapi/v1/analysis", body=dsl)
print(resp.content)
3.查询分析 OpenAPI 说明(私有化)

注意:私有化和SaaS有所不同,需要分为两个接口来获取查询结果。

3.1 使用 DSL 查询 API 定义

Context-Path: /datafinder
Path:/openapi/v1/analysis
Method: POST
Content-type: application/json
Body:

  • 请求参数均采用查询 DSL 进行描述

  • 数据编码为 UTF-8

Response:

{
        "code": 200,
        "message": "success"
        "data":  {
            "result_id": xxx
        }
}

字段含义说明

FieldTypeDescription
result_idint查询结果ID

3.2 获取 result_id 查询结果 API 定义

Context-Path: /datafinder
Path:/openapi/v1/analysis/{result_id}/result
Method: GET
Content-type: application/json
Path-parameters:

ParameterTypeDescriptionRequired
result_idint查询结果IDtrue

Response:
返回结构同SaaS的查询返回结构

3.3 OpenAPI SDK 使用样例

bc 为创建的 RangersClient, 其初始化请参考 “OpenAPI SDK 使用说明”, 各语言的 SDK 都提供了类似的接口

调用(Python):

dsl = {
    "version": 3,
    "app_ids": [164314],
    "use_app_cloud_id": True,
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 5,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "content": {
            "query_type": "event",
            "profile_groups_v2": [],
            "profile_filters": [],
            "queries": [
                [
                    {
                        "event_type": "origin",
                        "show_name": "活跃用户数",
                        "event_name": "app_launch",
                        "groups_v2": [],
                        "filters": [],
                        "show_label": "active_user",
                        "event_indicator": "event_users"
                    }
                ]
            ],
            "option": {
                "skip_cache": False
            }
        }
}

# 私有化逻辑
resp = bc.data_finder("/openapi/v1/analysis", body=dsl)
result_id = resp.json()["data"]["result_id"]
resp2 = bc.data_finder(f"/openapi/v1/analysis/{result_id}/result")
print(resp2.content)
4.如何快速构建 DSL

4.1 获取页面查询的 DSL(推荐)

先打开浏览器的开发者工具(快捷键F12),然后配置好查询条件,查看页面的 datafinder/api/v1/analysis 请求,该请求的body即为该查询的DSL,可以直接拷贝使用。

4.2 使用 OpenAPI 提供的 DSLBuilder

具体参考各语言版本的 OpenAPI SDK

5.DSL 结构说明

5.1 整体结构

{
    "version": 3, # 版本号
    "app_ids": [164314], # 查询应用唯一标识
    "use_app_cloud_id": True, # 使用应用云唯一标识
    "periods": [ # 查询时间范围定义
        {
            "granularity": "day", # 时间粒度,分钟/小时/天/周/月
            "type": "last", # 时间规则 最近x天或者范围
            "last": { # 最近x天定义
                "amount": 5, # 查询数量
                "unit": "day" # 查询单位
            },
            "timezone": "Asia/Shanghai" # 时区
        }
    ],
    "content": {
            "query_type": "event", # 查询类型
            "profile_groups_v2": [], # 公共属性分组
            "profile_filters": [], # 公共属性过滤
            "queries": [ # 查询定义
                [
                    {
                        "event_type": "origin", # 事件类型,原始事件,虚拟事件,圈选事件
                        "show_name": "活跃用户数", # 查询名称
                        "event_name": "app_launch", # 事件名称
                        "groups_v2": [], # 事件分组
                        "filters": [], # 事件过滤
                        "show_label": "active_user", # 结果标识
                        "event_indicator": "event_users" # 指标名称
                    }
                ]
            ],
            "option": { # 查询可选参数
                "skip_cache": False # 不跳过缓存
            }
        }
}

5.2 字段详细说明

DSL(Domain Specific Language) 简单来讲就是一个json格式的文本,来灵活的定义复杂的查询需求。

5.2.1 顶层结构

{
  "version": 3,             # DSL的版本,本文档中全部为3
  "app_ids": [],            # 目标app,支持多个    
  "use_app_cloud_id": true, # app_ids参数中是否为app_cloud_id。请设置为true,false仅供内部使用
  "periods": [{}],          # 查询时间段,支持多个
  "content": {},            # 具体的查询内容字段,与contents传一个,结构相同
  "contents": [{}], 
  "option": {},             # json格式数据,请求相关的选项参数,不同的查询各不相同
  "show_option": {}         # json格式数据,在结果中原样返回
}
字段类型取值与含义是否必须
versionintDSL的版本,本文档中全部为3true
app_idsint数组目标app,支持多个true
use_app_cloud_idbooleanpp_ids参数中是否为app_cloud_id。false仅供内部使用
periodsjson的数组查询时间段,支持多个true
contentjson具体的查询内容字段,与contents传一个,结构相同
contentsjson数组
optionjson请求相关的选项参数,不同的查询各不相同
show_optionjson在结果中原样返回,前端展示使用,不影响查询结果

5.2.2 periods字段

[{
  "granularity": "",
  "type": "",
  "last": {
    "unit":"",
    "amount":int
  },
  "range": [int,int]
  "timezone": "Asia/Shanghai",
  "interval": int,
  "real_time": boolean,
  "week_start": int
}]

字段取值与含义是否必须例子

type

时间范围类型。
取值为range(范围查询)、last(最近)、today(今天)、past_range(过去多少天)

默认range

last

type为last时,有效。相对时间
为json格式,amount表示数量,unit表示单位(支持day/week/month/year)

type为last是必须传

{
"unit":"day",
"amount":7
}

range

type为range时,有效。绝对时间
长度为2的整形数组,表示开始与截止时间。时间单位为秒

{range: [1586102400, 1588780799]}

spans

type为past_range时有效。是一个list,传2个,第一个代表开始时间,第二个代表结束时间。每一个list的结构为:

  • type 表示类型:

    • timestamp,表示具体的时间点;
  • past, 过去什么时间

  • timestamp,具体的时间点

  • past, 过去什么时间

    • amount 表示数量
  • unit表示单位,支持 day,week,month,year

  • offset, 表示时间的偏移量,比如28号1点-29号1点,起始时间的offset为3600,结束时间的offset为7199

{
        "granularity": "all",
        "align_unit":"day",
        "type": "past_range",
        "spans":[
            {
              "type": "timestamp",
              "timestamp": "1619798400",
              "offset":3600
            },
            {
                "type": "past",
                "past": {
                        "amount": 1,
                        "unit": "day"
                },
                "offset":7199
            }
        ]
        "timezone": "Asia/Shanghai"
}

granularity

时间粒度。对指定的时间范围按照时间粒度进行拆分
枚举值:

  • all(不进行拆分)
  • second
  • minute
  • five_minute
  • ten_minute
  • fifteen_minute
  • thirty_minute
  • hour
  • day
  • week
  • month
  • quarter
  • year

默认all

interval时间粒度。以自定义的时间粒度进行拆分,时间单位秒,比如130秒
timezone时间范围的时区默认Asia/Shanghai
real_time是否是实时查询,如果为true,只会查询实时的库。这部分会被option里面的real_time覆盖。
week_startgranularity为周时,可以指定周的起始日期。比如5表示 周五-周四默认1,周一到周日
align_unit对齐单元

5.2.3 content字段

{
  "profile_groups_v2": [],        #分组条件,只支持公共属性。
  "profile_filters": [{}],     #过滤条件
  "orders": [],                #排序规则
  "query_type": "",            #查询类型
  "queries": [[],[]],          #查询,二维数组。不同的查询类型需要设置不同的queries数组
  "option": {},                #查询选项
  "page": {},                  #查询分页,limit相关配置
}

profile_filters

[{
  "show_name": "1",
  "show_label": 1,
  "expression": {
    "logic": "and",
    "conditions": [{
      "property_name": "custom_server_gender",
      "property_type": "profile",
      "property_operation": "=",
      "property_values": ["1"]
    }]
  }
}]

说明

私有化里面 "property_type" : "profile" 需要修改为 "property_type": "user_profile"

字段类型取值与含义是否必须
show_namestring前端参数
show_labelstring前端参数
expressionjson条件表达式
logicstringexpression的conditions 的逻辑关系and/or
conditionsjson数组具体的条件
condition

单个条件

{
      "property_name": "custom_server_gender",
      "property_type": "profile",
      "property_operation": "=",
      "property_values": ["1"]
 }

说明

私有化里面 "property_type" : "profile" 需要修改为 "property_type": "user_profile"

字段类型取值与含义是否必须例子
property_namestring属性名称age、custom_server_gender

property_type

string

属性类型
profile(user_profile),event_param,common_param,cohort。如果是在profile_filters中,那么只能是profile(user_profile),common_param,cohort。
在queries里面的,则可以是profile,event_param,cohort, common_param

profile表示用户属性(saas),在私有化里面使用user_profile
event_param事件属性
common_param事件公共属性
cohort分群

property_operation

string

计算表达式
=
!=
is_null
is_not_null
in
not_in
>
>=
<
<=
contain
not_contain

不同的property_type支持的property_operation不一样

property_valuesstring/int/float数组属性的表达式的值

property_value_type

属性的表达式的值的类型

  • int
  • string
  • float
  • long

profile_groups_v2

"profile_groups_v2": [
    {
        "property_type":"profile",
        "property_name":"user_is_new"
    },
    {
        "property_type":"profile",
        "property_name":"os_name"
    }
]

说明

私有化里面 "property_type" : "profile" 需要修改为 "property_type": "user_profile"

字段类型取值与含义是否必须
profile_groups_v2json数组公共属性名称

query_type

查询的类型

  • 事件查询:event

  • 留存查询:retention

  • 转换查询:funnel

  • 用户路径查询:path_find

  • 生命周期查询:life_cycle

  • web查询:web_session

  • topk查询:event_topk

  • LTV查询:ltv

  • 归因查询:behavior_attribution

  • 成分查询:composition

  • 广告查询:advertise

  • 置信度查询:confidence

queries

查询条件,二维数组,不同的查询类型,需要组织对应的query数组。具体参考案例

{
  "event_name": "any_event",
  "event_id":1,
  "event_type": "origin",
  "show_name": "总次数",
  "groups_v2": [],
  "filters": [],
  "show_label": "A",
  "event_indicator": "events",
  "measure_info": {}
}
字段类型取值与含义是否必须
event_namestring事件名称
event_idint事件idevent_name和event_id必须有一个

event_type

string

事件类型
目前支持三种类型origin,virtual,bav

groups_v2string数组profile_groups_v2,只能取事件属性、事件公共属性
filter数组同profile_filters
show_labelstring前段参数

event_indicator

string

计算指标:

  • events: 总次数
  • event_users: 总人数
  • uv_per_au: 渗透率
  • events_per_user: 人均次数
  • pv_per_au: 全活跃用户人均次数
  • measure: 计算

measure_info

计算指标补充,在 event_indicator 为 measure 时使用

  • measure_type: sum 时,按...求和
  • measure_type: min 时,按...求最小值
  • measure_type: max 时,按...求最大值
  • measure_type: avg 时,按...求平均值
  • measure_type: per_user 时,按...求人均值
  • measure_type: sum_per_au 时,按...求全活跃用户人均值
  • measure_type: pct 时,按...求分位数
  • measure_type: distinct 时,按...求去重数
  • measure_type: distinct_user_attr 时,按...和用户去重

measure_info

{
  "event_indicator": "measure",
  "measure_info": {
      "measure_type": "sum",
      "property_name": "time"
  }
}
字段类型取值与含义是否必须

measure_type

string

测量尺度,可取值为:
SUM,
AVG,
MAX,
MIN,
PCT,
DISTINCT,
PER_USER,
DISTINCT_USER_ATTR,
COUNT_BY_DATE,
PLAIN

property_namestring计算属性

option

存放跟查询相关的特定的配置

{
}
字段类型取值与含义是否必须

refresh_cache

bool

是否刷新缓存。查询默认会走缓存,当希望跳过缓存并且更新缓存数据的时候,可以设置refresh_cache为true

window_period_type同granularity窗口时间单位特定的查询下是必须的:转化、用户路径
window_period窗口时间特定的查询下是必须的:转化、用户路径

lifecycle_query_type

active/ lost

active 活跃用户;
lost 流失用户

用户生命周期查询的时候是必须的

lifecycle_period

是一个json对象,属性固定为granularity,period

"granularity": 时间粒度
"period": 时间大小

用户生命周期查询的时候是必须的

page

存放跟查询分页相关的信息

"page": {
    "limit": 50,  # 指定最大返回条数
    "offset": 0
}
字段类型取值与含义是否必须

limit

int

指定要返回的最大数据条数。默认为 50,最大支持50000
注意:limit设置过大可能导致查询超时或异常失败

offsetint注意:offset字段尚处于开发阶段,目前生产环境上无法生效
6.常见 DSL 说明

6.1 事件查询:event

{
    "use_app_cloud_id": true,
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "content": {
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "query_type": "event",
        "queries": [
            [
                {
                    "event_name": "app_launch",
                    "event_type": "origin",
                    "show_name": "应用启动",
                    "groups_v2": [],
                    "filters": [],
                    "show_label": "A",
                    "event_indicator": "events",
                    "measure_info": {},
                    "indicator_show_name": "总次数"
                }
            ]
        ],
        "option": {
            "refresh_cache": false,
            "fusion": false
        }
    }
}

6.2 留存查询:retention

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "content": {
        "query_type": "retention",
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "queries": [
            [
                {
                    "show_label": "A",
                    "event_name": "app_launch",
                    "event_type": "origin",
                    "groups_v2": [],
                    "filters": []
                },
                {
                    "show_label": "",
                    "event_name": "any_active_event",
                    "event_type": "origin",
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "page": {
            "limit": 50,
            "offset": 0
        },
        "option": {
            "refresh_cache": true,
            "fusion": false
        }
    },
    "use_app_cloud_id": true

}

6.3 转化查询:funnel

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "content": {
        "query_type": "funnel",
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "page": {
            "limit": 50,
            "offset": 0
        },
        "queries": [
            [
                {
                    "show_label": "1",
                    "event_id": 234950,
                    "event_name": "app_launch",
                    "event_type": "origin",
                    "show_name": "",
                    "groups_v2": [],
                    "filters": []
                },
                {
                    "show_label": "2",
                    "event_id": 234950,
                    "event_name": "app_launch",
                    "event_type": "origin",
                    "show_name": "",
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "option": {
            "window_period": 10, 
            "window_period_type": "minute",
            "fusion": false,
            "refresh_cache": true
        }
    },
    "use_app_cloud_id": true

}

6.4 用户路径查询:path_find

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai",
            "interval": "604800"
        }
    ],
    "version": 3,
    "content": {
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "query_type": "path_find",
        "queries": [
            [
                {
                    "event_type": "origin",
                    "show_label": "A",
                    "groups_v2": [],
                    "filters": []
                },
                {
                    "event_type": "origin",
                    "show_label": "B",
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "option": {
            "refresh_cache": false,
            "hide_unselected": true,
            "window_period_type": "minute", 
            "window_period": 10 
        }
    },
    "use_app_cloud_id": true

}

6.5 生命周期查询:life_cycle

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "content": {
        "query_type": "life_cycle",
        "queries": [
            [
                {
                    "event_id": 516129,
                    "event_name": "any_active_event",
                    "event_type": "origin",
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "profile_filters": [
        ],
        "profile_groups_v2": [],
        "option": {
            "lifecycle_period": {
                "granularity": "day",
                "period": 1
            },
            "lifecycle_query_type": "active"
        }
    },
    "use_app_cloud_id": true

}

6.6 web查询:web_session

{
    "app_ids": [
        164155
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "contents": [
        {
            "profile_groups_v2": [],
            "profile_filters": [],
            "orders": [],
            "query_type": "web_session",
            "queries": [
                [
                    {
                        "event_type": "none",
                        "show_name": "访客数",
                        "groups_v2": [],
                        "filters": [
                            {
                                "expression": {
                                    "logic": "and",
                                    "conditions": [
                                        {
                                            "property_values": [
                                                null
                                            ],
                                            "property_type": "event_param",
                                            "property_name": "referer_type",
                                            "property_operation": "is not null"
                                        }
                                    ]
                                }
                            }
                        ],
                        "show_label": "uv",
                        "event_indicator": "uv"
                    }
                ]
            ],
            "option": {
                "refresh_cache": false,
                "fusion": true
            }
        }
    ],
    "use_app_cloud_id": true

}

6.7 topk查询:event_topk

{
    "app_ids": [
        "164314"
    ],
    "use_app_cloud_id": true,
    "version": "3.0",
    "periods": [
        {
            "granularity": "day",
            "align_unit": "day",
            "timezone": "Asia/Shanghai",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            }
        }
    ],
    "content": {
        "show_option": {},
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "query_type": "event_topk",
        "queries": [
            [
                {
                    "event_type": "none",
                    "event_indicator": "pv",
                    "show_name": "",
                    "show_label": "",
                    "event_name": null,
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "option": {
        }
    }
}

6.8 LTV查询:ltv

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "day",
            "type": "last",
            "last": {
                "amount": 60,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai"
        }
    ],
    "version": 3,
    "content": {
        "query_type": "ltv",
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "queries": [
            [
                {
                    "show_label": "",
                    "event_name": "purchase",
                    "event_type": "origin",
                    "groups_v2": [],
                    "filters": [],
                    "event_indicator": "measure",
                    "measure_info": {
                        "measure_type": "plain",
                        "property_name": "currency_amount"
                    }
                },
                {
                    "show_label": "",
                    "event_name": "any_event",
                    "event_type": "origin",
                    "groups_v2": [],
                    "filters": []
                }
            ]
        ],
        "page": {
            "limit": 10,
            "offset": 2
        },
        "option": {}
    },
    "use_app_cloud_id": true

}

6.9 归因查询:behavior_attribution

{
    "use_app_cloud_id": true,
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "granularity": "all",
            "type": "last",
            "last": {
                "amount": 7,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai",
            "interval": "604800"
        }
    ],
    "version": 3,
    "content": {
        "profile_groups_v2": [],
        "profile_filters": [],
        "orders": [],
        "query_type": "behavior_attribution",
        "queries": [
            [
                {
                    "event_name": "purchase",
                    "event_type": "origin",
                    "show_name": "支付",
                    "groups_v2": [],
                    "event_indicator": "events",
                    "show_label": "A",
                    "measure_info": {},
                    "filters": []
                }
            ],
            [],
            [
                {
                    "event_name": "app_launch",
                    "event_type": "origin",
                    "show_name": "应用启动",
                    "groups_v2": [],
                    "event_indicator": "events",
                    "show_label": "A",
                    "measure_info": {},
                    "filters": []
                }
            ]
        ],
        "option": {
            "refresh_cache": true,
            "attribution_type": "last",
            "window_period": 0,
            "window_period_type": "day",
            "is_other_contact": false
        },
        "page": {
            "limit": 50,
            "offset": 0
        }
    }
}

6.10 成分查询:composition

{
    "app_ids": [
        164314
    ],
    "periods": [
        {
            "type": "last",
            "last": {
                "amount": 30,
                "unit": "day"
            },
            "timezone": "Asia/Shanghai",
            "align_unit": "day",
            "granularity": "all"
        }
    ],
    "version": 3,
    "content": {
        "query_type": "composition",
        "profile_groups_v2": [
            {
                "property_type" : "profile",
                "property_name": "age"
            }
        ],
        "profile_filters": [],
        "orders": [],
        "queries": [
            [
                {
                    "event_type": "none"
                }
            ]
        ],
        "option": {
            "refresh_cache": false
        }
    },
    "use_app_cloud_id": true

}

说明

私有化里面 "property_type" : "profile" 需要修改为 "property_type": "user_profile"

6.11 属性查询:attribute

{
    "use_app_cloud_id": true,
    "app_ids": [
        164314
    ],
    "periods": [
        {
            //只支持all粒度,不支持按时间粒度分组
            "granularity": "all",
            "type": "past_range",
            "spans": [
                {
                    "type": "past",
                    "past": {
                        "amount": 7,
                        "unit": "day"
                    }
                },
                {
                    "type": "past",
                    "past": {
                        "amount": 1,
                        "unit": "day"
                    }
                }
            ],
            "timezone": "Asia/Shanghai",
            "week_start": 1,
            "align_unit": "day"
        }
    ],
    "version": 3,
    "content": {
        "profile_groups_v2": [],
        "profile_filters": [],
        //自定义排序字段
        "orders": [
        {   //field形式为{property_type}#{property_name}的形式,direction为desc(降序)或者asc(升序)
                "field": "profile#loc_city_id",
                "direction": "desc"
            }
        ],
        //自定义分页字段,limit最大为10000,超过10000按10000处理
        "page": {
            "limit": 50,
            "offset": 0
        },
        //查询类型,仅支持openApi
        "query_type": "attribute",
        "queries": [
            [
                {
                    "indicator_show_name": "",
                    "measure_info": {},
                    "show_name": "",
                    "show_label": "A",
                    "event_name": "any_event",
                    "event_type": "origin",
                    "event_indicator": "None",
                    "filters": [],
                    //需要查询的属性
                    "groups_v2": [
                        {
                            "property_compose_type": "origin",
                            "property_name": "$event_name",
                            "property_type": "common_param"
                        },
                        {
                            "property_compose_type": "origin",
                            "property_name": "loc_city_id",
                            "property_type": "profile"
                        },
                        {
                            "property_compose_type": "virtual",
                            "property_name": "$_vp_zylvirtual",
                            "property_type": "common_param"
                        }
                    ],
                    "extra": {}
                }
            ]
        ],
        "option": {
            //是否分页(必传true)
            "is_paginate": true
        }
    },
    "option": {}
}

说明

该DSL特用于多个属性分组,且分组值数量较大的查询场景,在此特定场景下支持分页。

查询限制:

  • 不支持item属性的查询
  • 必须指定事件名+日期
  • 只支持同一事件下的属性查询
  • 支持虚拟事件以及虚拟属性
  • 最多同时支持5个属性的查询(超过5个的会被抛弃)
  • 不支持时间粒度分组,仅支持granularity: all

特别说明:

  • event_indicator需要固定传None。
  • is_paginate代表是否分页,必传true,否则只会取前page.limit条结果。
  • groups_v2在query type 为attribute的情况下传需要查询的属性列表。