Skip to main content

Retention Analysis model API

Last updated 10/03/2026

For how to call the API, see the calling method described in the Open API document.

To learn about usage scenarios, read Retention Analysis in the User Guide.

1. Retention Analysis query​

Endpoint URL

/open/retention-analyze?token=xxx

Request method

POST

Content-Type

application/json

Request query parameters

Parameter nameExample valueParameter typeRequiredDescription
tokenxxxStringYesQuery key

Request body parameters​

{
"eventView":{
"endTime":"2021-10-30 23:59:59",
"filts":[
{
"columnDesc":"App version",
"columnName":"app_version",
"comparator":"equal",
"filterType":"SIMPLE",
"ftv":[
"V1.0"],
"specifiedClusterDate":"2022-01-24",
"tableType":"event",
"timeUnit":""
}],
"firstDayOfWeek":1,
"groupBy":[
{
"columnDesc":"Browser",
"columnName":"browser",
"propertyRange":"",
"specifiedClusterDate":"2022-01-24",
"tableType":"event"
}],
"recentDay":"",
"relation":"and",
"startTime":"2021-10-01 00:00:00",
"statType":"retention",
"taIdMeasureVo":{
"columnDesc":"User Unique ID",
"columnName":"#user_id",
"tableType":"event"
},
"timeParticleSize":"week",
"unitNum":1
},
"events":[
{
"eventName":"login",
"eventNameDisplay":"",
"filts":[
{
"columnDesc":"app_version",
"columnName":"app_version",
"comparator":"equal",
"filterType":"SIMPLE",
"ftv":["V1.0"],
"specifiedClusterDate":"2022-01-26",
"tableType":"event",
"timeUnit":""
}],
"relation":"and",
"relationUser":"and",
"type":"first"
},
{
"eventName":"logout",
"eventNameDisplay":"",
"filts":[
],
"relation":"and",
"relationUser":"and",
"type":"second"
},
{
"analysis":"TOTAL_TIMES",
"analysisDesc":"Event total",
"eventName":"activity_attend",
"eventNameDisplay":"",
"filts":[
],
"quota":"",
"relation":"and",
"relationUser":"and",
"type":"simultaneous_display"
}],
"projectId": 377,
"limit": 2,
"timeoutSeconds": 10,
"useCache": true,
"zoneOffset": 10
}

Request parameters​

$$Parameter nameExample valueParameter typeRequiredDescription
eventView-ObjectYesCommon properties of the metrics
eventView.endTime2021-10-30 23:59:59StringNoEnd time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty
eventView.filts-ListNoGlobal filters
eventView.filts.columnDescApp versionStringNoField display name
eventView.filts.columnNameapp_versionStringYesField name
eventView.filts.comparatorequalStringYesSee Filter expressions in the Query API
eventView.filts.filterTypeSIMPLEStringNoFilter mode. SIMPLE: simple, COMPOUND: compound
eventView.filts.ftv["V1.0"]ListNoLiteral constants used as boundaries for property comparison
eventView.filts.specifiedClusterDate2022-01-24StringNoUses the historical version of the tag for the specified date
eventView.filts.tableTypeeventStringYesTable type enum values
eventView.filts.timeUnitStringNoUnit of the property comparison value, valid only for relativeEvent*: day, hour, minute
eventView.firstDayOfWeek1IntegerNoWhen timeParticleSize is week, specifies the first day of the week. 1: Monday, 2: Tuesday, .., 7: Sunday. Minimum 1, maximum 7
eventView.groupBy-ListNoGroup-by properties. There can be zero or more
eventView.groupBy.columnDescBrowserStringNoField display name
eventView.groupBy.columnNamebrowserStringYesField name
eventView.groupBy.propertyRangeStringNoCustom property range
eventView.groupBy.specifiedClusterDate2022-01-24StringNoUses the historical version of the tag for the specified date
eventView.groupBy.tableTypeeventStringYesTable type enum values
eventView.recentDayStringNoRelative time (this item, the start time, and the end time can't all be empty)
eventView.relationandStringNoLogical relation. and: logical AND, or: logical OR
eventView.startTime2021-10-01 00:00:00StringNoStart time (format: yyyy-MM-dd HH:mm:ss). Takes effect when the relative time is empty
eventView.statTyperetentionStringYesStatistics type. retention: retention; lost: churn
eventView.taIdMeasureVo-ObjectNoAnalysis entity configuration
eventView.taIdMeasureVo.columnDescUser Unique IDStringNoField display name
eventView.taIdMeasureVo.columnName#user_idStringYesField name
eventView.taIdMeasureVo.tableTypeeventStringYesTable type enum values

eventView.timeParticleSize

week

String

Yes

Time unit of the analysis

  • day: daily
  • week: weekly
  • month: monthly
eventView.unitNum1IntegerYesRetention period
events-ListYesList of event metrics
events.eventNameloginStringYesEvent name of the metric. You can use anyEvent to represent any event
events.eventNameDisplayStringNoDisplay name of the custom metric
events.analysisTRIG_USER_NUMStringNoAnalysis type (aggregation operation). For details, see Retention Also Show aggregation type enum values
events.analysisDescEvent totalStringNoDescription of the analysis type
events.quotaStringNoMetric property (used with analysis to specify which analysis type of which property)
events.filts-ListNoList of conditions
events.filts.columnDescapp_versionStringNoField display name
events.filts.columnNameapp_versionStringYesField name
events.filts.comparatorequalStringYesSee Filter expressions in the Query API
events.filts.filterTypeSIMPLEStringNoFilter mode. SIMPLE: simple, COMPOUND: compound
events.filts.ftv["V1.0"]ListNoLiteral constants used as boundaries for property comparison
events.filts.specifiedClusterDate2022-01-26StringNoUses the historical version of the tag for the specified date
events.filts.tableTypeeventStringYesTable type enum values
events.filts.timeUnitStringNoTime unit of the filter
events.relationandStringNoLogical relation. and: logical AND, or: logical OR
events.relationUserandStringNoLogical relation of user filters. and: logical AND, or: logical OR

events.type

first

StringYes

Retention event type:

  • first: first event
  • second: return event
  • simultaneous_display: Also Show
  • init_date_stat: metric on the initial date
projectId377IntegerYesProject ID
limit2IntegerNoMaximum number of groups per analysis object. Optional. Defaults to 1000, with a maximum of 10000
timeoutSeconds10IntegerNoRequest timeout. The query task is canceled when it times out
useCachetrueBooleanYestrue means the cache is used
zoneOffset10IntegerNoTime zone

Success response example​

{
"data": {
"result_generate_time": "2022-01-01 00:00:00",
"state_avg": {
"0": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.998"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"0.9981"
]
}
],
"1": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [
"-",
"4"
],
"values": [
"-",
"1"
]
}
],
"2": [
{
"groupCols": [
"Overall"
],
"initNum": 0,
"isTotal": 1,
"lastValidDateVerticalIndexs": [],
"values": [
"-",
"132405.4"
]
},
{
"groupCols": [
"Chrome"
],
"initNum": 0,
"isTotal": 0,
"lastValidDateVerticalIndexs": [],
"values": [
"-",
"66343.2"
]
}
]
},
"x": [
"2021-09-27",
"2021-10-04",
"2021-10-11",
"2021-10-18",
"2021-10-25"
],
"y": {
"0": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7374"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3642"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7844"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3930"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"7994"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4054"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8543"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4218"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"7414",
"7397"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"3741",
"3733"
]
}
]
},
"1": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"7388",
"7388"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"3647",
"3647"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"7861",
"7861"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"3939",
"3939"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"8013",
"8013"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"4062",
"4062"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"8553",
"8553"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"4225",
"4225"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"7414",
"7414"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"3741",
"3741"
]
}
]
},
"2": {
"2021-09-27": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7388,
"isTotal": 1,
"values": [
"0",
"125324"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3647,
"isTotal": 0,
"values": [
"0",
"62105"
]
}
],
"2021-10-04": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7861,
"isTotal": 1,
"values": [
"0",
"132130"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3939,
"isTotal": 0,
"values": [
"0",
"65971"
]
}
],
"2021-10-11": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8013,
"isTotal": 1,
"values": [
"0",
"134691"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4062,
"isTotal": 0,
"values": [
"0",
"68566"
]
}
],
"2021-10-18": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 8553,
"isTotal": 1,
"values": [
"0",
"144030"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 4225,
"isTotal": 0,
"values": [
"0",
"71345"
]
}
],
"2021-10-25": [
{
"groupCols": [
"Overall"
],
"includeToday": false,
"initNum": 7414,
"isTotal": 1,
"values": [
"0",
"125852"
]
},
{
"groupCols": [
"Chrome"
],
"includeToday": false,
"initNum": 3741,
"isTotal": 0,
"values": [
"0",
"63729"
]
}
]
}
},
"z": [
"login",
"logout",
"activity_attend"
]
},
"return_code": 0,
"return_message": "success"
}

Response parameters​

$$Parameter nameExample valueParameter typeDescription
return_code0IntegerReturn code
return_messagesuccessStringReturn message
data-ObjectReturned result
data.result_generate_time2022-01-01 00:00:00StringResult generation time
data.state_avg-ObjectResult map. The key is type, and the value is the retention groups
data.state_avg.{type}-ListValue of type. 0: retention; 1: churn; 2: Also Show metric
data.state_avg.{type}.groupCols["Overall"]ListGroup columns
data.state_avg.{type}.initNum0IntegerInitial value
data.state_avg.{type}.isTotal1IntegerWhether it's the total. 1: yes; 0: no
data.state_avg.{type}.lastValidDateVerticalIndexs["-", "4"]ListIndex of the last date with complete data
data.state_avg.{type}.values["-", "0.998"]ListValue list: "-" or a number
data.x["2021-09-27"]ListDate list
data.y-ObjectY-axis data
data.y.{type}-ObjectValue of type. 0: retention; 1: churn; 2: statistics
data.y.{type}.{date}-ListThe key is the date
data.y.{type}.{date}.groupCols["Overall"]ListGroup columns
data.y.{type}.{date}.includeTodayfalseBooleanWhether today is included
data.y.{type}.{date}.initNum7388IntegerInitial value
data.y.{type}.{date}.isTotal1IntegerWhether it's the total. 1: yes; 0: no
data.y.{type}.{date}.values["7388"]ListValue list
data.z["login"]ListEvent name list

Error response example

{
"return_code": -1008,
"return_message": "Parameter (token) is empty"
}
Parameter nameExample valueParameter typeDescription
return_code-1008IntegerReturn code
return_messageParameter (token) is emptyStringReturn message

2. Retention Analysis full download​

Endpoint URL

/open/streaming-download/retention-analyze?token=xxx

Request method

POST

Content-Type

application/json

Request query parameters

Parameter nameExample valueParameter typeRequiredDescription
tokenxxxStringYesQuery key

Request body parameters​

{
"eventView": {
"collectFirstDay": 1,
"endTime": "2022-03-08 16:55:10",
"filts": [],
"groupBy": [{
"columnDesc": "Channel",
"columnName": "channel",
"propertyRange": "",
"specifiedClusterDate": "2022-03-09",
"tableType": "event"
}],
"recentDay": "1-7",
"relation": "and",
"startTime": "2022-03-02 16:55:10",
"statType": "retention",
"taIdMeasureVo": {
"columnDesc": "User Unique ID",
"columnName": "#user_id",
"tableType": "event"
},
"timeParticleSize": "day",
"unitNum": 7
},
"events": [{
"eventName": "Recharge",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "first"
}],
"projectId": 390
}

Request parameters​

$$Parameter nameExample valueParameter typeRequiredDescription
eventView-ObjectYesSame as the parameters of the Retention Analysis query API
events-ListYesSame as the parameters of the Retention Analysis query API
projectId377IntegerYesProject ID
zoneOffset10IntegerNoTime zone

Response​

Same as the Retention Analysis full download in AE

3. Retention Analysis user list​

Endpoint URL

/open/retention-user-list?token=xxx

Request method

POST

Content-Type

application/json

Request query parameters

Parameter nameExample valueParameter typeRequiredDescription
tokenxxxStringYesQuery key

Request body parameters​

{
"projectId": 0,
"eventView": {
"startTime": "2019-11-24 00:00:00",
"endTime": "2019-11-26 00:00:00",
"recentDay": "1-3",
"statType": "retention",
"timeParticleSize": "day",
"unitNum": 7,
"groupBy": [
{
"columnName": "#province",
"tableType": "event"
}
]
},
"events": [
{
"type": "first",
"relation": "and",
"eventName": "player_register",
"filts": [
{
"columnName": "#province",
"comparator": "equal",
"ftv": [
"Jiangsu",
"Shanghai"
],
"tableType": "event"
},
{
"columnName": "user_level",
"comparator": "greater",
"ftv": [
"2"
],
"tableType": "user"
}
]
},
{
"type": "second",
"relation": "and",
"eventName": "obtain_diamond",
"filts": [
{
"columnName": "#os",
"comparator": "equal",
"ftv": [
"android"
],
"tableType": "event"
},
{
"$ref": "$.events[0].filts[1]"
}
]
}
],
"sliceDate": "2019-11-26",
"sliceInterval": 3,
"timeoutSeconds": 10,
"zoneOffset": 10
}

Request parameters​

$$Parameter nameExample valueParameter typeRequiredDescription
projectId0StringYesDescription
eventView-ObjectYesSame as the parameters of the Retention Analysis query API
eventsListYesSame as the parameters of the Retention Analysis query API
sliceDate"2019-11-26"StringNoDate to drill down into
sliceGroupVal["Beijing"]ListYesGroup to drill down into

sliceInterval

3ListYes

Index of the retention interval to drill down into

  • 0: initial event users
  • 1: the same day
  • 2: 1 day later
  • 3: 2 days later
timeoutSeconds10IntegerNoRequest timeout. The query task is canceled when it times out
zoneOffset10IntegerNoTime zone

Success response example​

{
"data": {
"datalist": [
{
"#account_id": "v47739399",
"#distinct_id": "v88658799",
"user_level": 11,
"register_time": "2019-11-26 19:13:20",
"diamond_num": 1182,
"latest_login_time": "2019-11-26 20:16:19",
"channel": "Huawei AppGallery",
"#user_id": 20459799
},
{
"#account_id": "i7819568",
"#distinct_id": "i14522048",
"user_level": 4,
"register_time": "2019-11-26 23:56:17",
"diamond_num": 1006,
"latest_login_time": "2019-11-26 23:59:59",
"channel": "360 Mobile Assistant",
"#user_id": 3351248
},
{
"#account_id": "g7812426",
"#distinct_id": "g14508786",
"user_level": 14,
"register_time": "2019-11-26 17:54:13",
"diamond_num": 245,
"first_recharge_time": "2019-11-26 18:08:58",
"latest_login_time": "2019-11-26 20:16:19",
"channel": "Xiaomi GetApps",
"#user_id": 3348186
},
{
"#account_id": "a7812000",
"#distinct_id": "a14508000",
"user_level": 3,
"register_time": "2019-11-26 17:27:28",
"diamond_num": 1153,
"latest_login_time": "2019-11-26 18:45:58",
"channel": "app store",
"#user_id": 3348000
}
],
"columMeta": {
"#account_id": "Account ID",
"#distinct_id": "Distinct ID",
"user_level": "User Level",
"register_time": "Registration Time",
"diamond_num": "Current Diamonds",
"first_recharge_time": "First Top-up Time",
"latest_login_time": "Last Login Time",
"channel": "Channel"
}
},
"return_code": 0,
"return_message": "success"
}

Response parameters​

Parameter nameExample valueParameter typeDescription
return_code0IntegerReturn code
return_messagesuccessStringReturn message
data-ObjectReturned result
data.datalist-List<Map>User information
data.columMeta-MapMapping of field meanings

Error response example

{
"return_code": -1008,
"return_message": "Parameter (token) is empty"
}
Parameter nameExample valueParameter typeDescription
return_code-1008IntegerReturn code
return_messageParameter (token) is emptyStringReturn message

4. Retention Analysis user list download​

Endpoint URL

/open/streaming-download/retention-user-list?token=xxx

Request method

POST

Content-Type

application/json

Request query parameters

Parameter nameExample valueParameter typeRequiredDescription
tokenxxxStringYesQuery key

Request body parameters​

{
"eventView": {
"collectFirstDay": 1,
"endTime": "2022-03-07 17:09:58",
"filts": [],
"groupBy": [],
"recentDay": "1-7",
"relation": "and",
"startTime": "2022-03-01 17:09:58",
"statType": "retention",
"taIdMeasureVo": {
"columnDesc": "User ID",
"columnName": "#user_id",
"tableType": "event"
},
"timeParticleSize": "day",
"unitNum": 7
},
"events": [{
"eventName": "Login",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "first"
}, {
"eventName": "Recharge",
"eventNameDisplay": "",
"filts": [],
"relation": "and",
"relationUser": "and",
"type": "second"
}],
"projectId": 319,
"isLost": false,
"sliceDate": "2022-03-01",
"sliceInterval": 0,
"selectedColumns": ["#account_id", "#distinct_id"],
"zoneOffset": 10
}

Request parameters​

$$Parameter nameExample valueParameter typeRequiredDescription
eventView-ObjectYesSame as the parameters of the Retention Analysis query API
events-ListYesSame as the parameters of the Retention Analysis query API
projectId377IntegerYesProject ID
isLostfalsebooleanNoWhether the users churned
sliceDate"2019-11-26"StringNoDate of the event
sliceGroupVal["Beijing"]ListYesGroup to drill down into
sliceInterval0IntegerYes

Index of the retention interval to drill down into

  • 0: initial event users
  • 1: the current {date unit}
  • 2: 1 {date unit} later
  • 3: 2 {date units} later
selectedColumns["#account_id"]ListYesColumns to download
zoneOffset10IntegerNoTime zone
tip

You can export the request body from the Retention Analysis page in AE, and then add the isLost, sliceDate, sliceGroupVal, sliceInterval, and selectedColumns parameters

Response​

Same as the Retention Analysis user list full download in AE

Retention Analysis common enums​

Retention Also Show aggregation type enum values​

ValueDescriptionRequires property
TOTAL_TIMESEvent totalNo
TRIG_USER_NUMUniquesNo
PER_CAPITA_TIMESTimes per userNo
SUMSumYes
PER_CAPITA_NUMPer UserYes
STAGE_ACCCumulative sumYes
STAGE_ACC_PCVCumulative averageYes
TRUETrue totalsYes
FALSEFalse totalsYes
IS_NOT_EMPTYNot null totalsYes
IS_EMPTYNull totalsYes
Was this page helpful?