Metric query API
For how to call the API, see the calling method described in the Open API document.
We recommend that you first read the AE user guide to learn about the metric-related features: Metrics
1. Query the list of available metrics
Query the definition of metrics by conditions
Endpoint URL
/open/metric-list?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"projectId": 102,
"metricName": "retention_1", //Metric name - supports fuzzy matching
"metricDesc": "Day-1 retention", // Metric display name - supports fuzzy matching
"metricModes": ["EVENT","RETENTION"], // Metric creation source
"createUser":"root", //Creator
"updateUser":"root", //Last modified by
"timeParticleSize":"day" //Time granularity supported by the metric
}
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| projectId | 102 | Integer | Yes | Project ID |
| metricName | retention_1 | String | No | Metric name - supports fuzzy matching |
| metricDesc | Day-1 retention | String | No | Metric display name - supports fuzzy matching |
| metricModes | ["EVENT", "RETENTION"] | List | No | Metric creation source EVENT - event metric RETENTION - retention metric |
| createUser | root | String | No | Login name of the metric creator |
| updateUser | root | String | No | Login name of the user who modified the metric |
| timeParticle | day | String | No | Time unit supported by the metric
|
Response parameters
{
"data":
[
{
"metricId": 1,
"projectId": 2,
"metricName": "retention_1",
"metricDesc": "Day-1 retention",
"metricRemark": "Day-1 retention of registered users",
"metricMode": "EVENT",
"createUser": "root",
"updateUser": "root",
"createTime": "2022-12-12 10:10:00",
"updateTime": "2022-12-12 10:10:00",
"timeParticles":[ "minute"],
"format": "FORMAT_FLOAT"
}
],
"return_code": 0,
"return_message": "success"
}
| Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| data | - | Returned result | |
| data.metricId | 1 | Long | Metric ID |
| data.projectId | 102 | Integer | ID of the project that the metric belongs to |
| data.metricName | retention_1 | String | Metric name |
| data.metricDesc | Day-1 retention | String | Metric display name |
| data.metricRemark | Day-1 retention of registered users | String | Metric remarks |
| data.metricMode | RETENTION | String | Metric creation source |
| data.createUser | root | String | User who created the metric |
| data.updateUser | root | String | User who modified the metric |
| data.createTime | 2022-12-12 10:10:00 | Date | Metric creation date |
| data.updateTime | 2022-12-12 10:10:00 | Date | Metric modification date |
| data.timeParticles | ['day', 'hour', 'month'] | List | Time unit supported by the metric
|
| data.format | FORMAT_FLOAT | String | Metric format
|
| return_code | 0 | Integer | Return code |
| return_message | success | String | Return message |
2. Query metric data
Endpoint URL
/open/metric-data?token=xxx
Request method
POST
Content-Type
application/json
Request query parameters
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| token | xxx | String | Yes | Query key |
Request body parameters
{
"eventView": {
"comparedByTime": true,
"comparedStartTime": "2021-12-14 00:00:00",
"comparedEndTime": "2021-12-20 23:59:59",
"comparedRecentDay": "8-14",
"startTime": "2021-12-21 00:00:00",
"endTime": "2021-12-27 23:59:59",
"recentDay": "1-7",
"timeParticleSize": "day",
"groupBy": [{
"columnDesc": "Brand",
"columnName": "brand",
"propertyRange": "",
"specifiedClusterDate": "2021-12-28",
"tableType": "event"
}],
"relation": "and",
"filts": [{
"columnDesc": "Brand",
"columnName": "brand",
"comparator": "equal",
"filterType": "SIMPLE",
"ftv": ["Apple", "Xiaomi"],
"specifiedClusterDate": "2021-12-28",
"tableType": "event",
"timeUnit": ""
}],
"queryFeature": {
"approximateOn": true,
"globalQueryOn": false
}
},
"metrics":["retention_1","dau"],
"zoneOffset": 0,
"projectId": 377,
"useSameResultKey": false,
"useCache": true,
"limit": 1000,
"timeoutSeconds": 10
}
| Parameter name | Example value | Parameter type | Required | Description |
|---|---|---|---|---|
| eventView | - | Object | Yes | Common properties of the metrics |
| eventView.comparedByTime | true | Boolean | No | Whether to compare time. TRUE: yes, FALSE: no |
eventView.comparedStartTime | 2021-12-14 00:00:00 | String | No | Start time of the comparison period (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative comparison time is empty |
| eventView.comparedEndTime | 2021-12-20 23:59:59 | String | No | End time of the comparison period (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative comparison time is empty |
| eventView.comparedRecentDay | 8-14 | String | No | Relative comparison time (when comparedByTime is TRUE, this item, the comparison start time, and the comparison end time can't all be empty) |
| eventView.startTime | 2021-12-21 00:00:00 | String | No | Start time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty |
| eventView.endTime | 2021-12-27 23:59:59 | String | No | End time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty |
| eventView.recentDay | 1-7 | String | No | Relative time (this item, the start time, and the end time can't all be empty) |
| eventView.relation | and | String | No | Logical relation. and: logical AND, or: logical OR |
eventView.timeParticleSize | day | String | Yes | Time unit of the analysis
|
| eventView.groupBy | - | List | No | Group-by properties. There can be zero or more |
| eventView.groupBy.columnName | brand | String | Yes | Field name |
| eventView.groupBy.columnDesc | Brand | String | No | Field display name |
| eventView.groupBy.propertyRange | String | No | Custom property range | |
| eventView.groupBy.propertyRangeType | String | No | Property range type. When you group by a numeric property, you can use custom bucketing conditions
| |
| eventView.groupBy.specifiedClusterDate | 2021-12-28 | String | No | Uses the historical version of the tag for the specified date |
| eventView.groupBy.tableType | event | String | Yes | Table type enum values |
| eventView.filts | - | List | No | Global filters |
| eventView.filts.columnDesc | Brand | String | No | Field display name |
| eventView.filts.columnName | brand | String | Yes | Field name |
| eventView.filts.comparator | equal | String | Yes | See Filter expressions in the Query API |
| eventView.filts.filterType | SIMPLE | String | No | Filter mode. SIMPLE: simple, COMPOUND: compound. Defaults to SIMPLE |
| eventView.filts.ftv | ["Apple", "Xiaomi"] | List | No | Literal constants used as boundaries for property comparison |
| eventView.filts.specifiedClusterDate | 2021-12-28 | String | No | Uses the historical version of the tag for the specified date |
| eventView.filts.tableType | event | String | Yes | Table type enum values |
| eventView.filts.timeUnit | String | No | Unit of the property comparison value, valid only for relativeEvent*: day, hour, minute | |
| eventView.queryFeature | - | Object | No | Query configuration |
| eventView.queryFeature.approximateOn | true | Boolean | No | Whether to enable approximate calculation |
| metrics | ["retention_1","dau"] | list | Yes | List of metric names |
| projectId | 377 | Integer | Yes | Project ID |
zoneOffset | 0 | Integer | No | Time zone used |
| useCache | true | Boolean | No | Whether to use the cache. Optional. Defaults to true |
| limit | 1000 | Integer | No | Maximum number of groups per analysis object. Optional. Defaults to 1000, with a maximum of 10000 |
| timeoutSeconds | 10 | Integer | No | Request timeout. The query task is canceled when it times out |
Success response example
{
"data": {
"result_generate_time": "2021-12-30 11:15:41",
"union_groups": [
[
"Safari",
"Apple"
],
[
"Firefox",
"Xiaomi"
],
[
"WeChat built-in browser",
"Apple"
],
[
"Overall",
"Apple"
],
[
"Overall",
"Xiaomi"
]
],
"x": [
"2021-12-23",
"2021-12-24",
"2021-12-25",
"2021-12-26",
"2021-12-27",
"2021-12-28",
"2021-12-29"
],
"x_compared": [
"2021-12-16",
"2021-12-17",
"2021-12-18",
"2021-12-19",
"2021-12-20",
"2021-12-21",
"2021-12-22"
],
"y": [
{
"retention_1": [
{
"group_cols": [
"Safari",
"Apple"
],
"group_num": 3,
"values": [
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"values_compared": [
"447",
"980",
"1584",
"321",
"285",
"74",
"0"
]
},
{
"group_cols": [
"Firefox",
"Xiaomi"
],
"group_num": 3,
"values": [
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"values_compared": [
"291",
"818",
"1128",
"272",
"219",
"58",
"0"
]
},
{
"group_cols": [
"WeChat built-in browser",
"Apple"
],
"group_num": 3,
"values": [
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"values_compared": [
"231",
"500",
"764",
"214",
"155",
"35",
"0"
]
}
]
},
{
"dau": [
{
"group_cols": [
"Overall",
"Apple"
],
"group_num": 2,
"values": [
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"values_compared": [
"640",
"811",
"1251",
"1253",
"720",
"113",
"0"
]
},
{
"group_cols": [
"Overall",
"Xiaomi"
],
"group_num": 2,
"values": [
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"values_compared": [
"277",
"439",
"600",
"666",
"364",
"59",
"0"
]
}
]
}
]
},
"return_code": 0,
"return_message": "success"
}
Response parameters
| Parameter name | Example value | Parameter type | Description |
|---|---|---|---|
| data | - | Object | Returned result |
| data.result_generate_time | 2021-12-29 12:00:00 | String | Query result generation time |
| data.union_groups | ["Apple"] | List | Set of all groups |
| data.x | ["2021-12-23"] | List | X-axis time |
| data.x_compared | ["2021-12-16"] | List | X-axis comparison time |
| data.y | - | List | List of Y-axis data |
| data.y.{metric name} | - | List | List of Y-axis metric information |
| data.y.{metric name}.group_cols | ["Apple"] | List | Y-axis metric groups |
| data.y.{metric name}.group_num | 3 | Integer | Number of Y-axis metric groups |
| data.y.{metric name}.values | ["0"] | List | Y-axis metric values |
| data.y.{metric name}.values_compared | ["447"] | List | Y-axis metric values for the comparison period |
| return_code | 0 | Integer | Return code |
| return_message | success | String | Return message |

