行为分析
接口说明
获取小程序的用户行为分析数据。数据内容与“小程序控制台-数据-数据中心-用户-行为分析”页面保持一致。
使用限制
- 每日 10:00 前更新前一日数据
- 只能查询昨天以前,且是近90天内的数据
基本信息
名称 | 描述 |
---|---|
HTTP URL | https://open.douyin.com/api/platform/v2/data_analysis/query_behavior_data/ |
HTTP Method | GET |
权限要求 | 服务商代调用场景下,需商家授予数据分析权限集 |
请求参数
请求头
access-token必填String
当非服务商时,调用https://open.douyin.com/oauth/client_token/生成的token
当服务商时,调用https://open.douyin.com/api/tpapp/v2/auth/get_auth_token/生成的token
当服务商时,调用https://open.douyin.com/api/tpapp/v2/auth/get_auth_token/生成的token
Query
end_time必填Int64
结束时间,必须是昨天以前的某个时间戳
start_time必填Int64
开始时间,必须是昨天以前的某个时间戳
host_nameString
宿主APP,douyin-抖音;douyin_lite-抖音lite;toutiao-今日头条;tt_lite-今日头条lite;huoshan-抖音火山版;
osString
操作系统,ios或者android
version_typeString
版本类型。online-线上版本;gray-灰度版本
请求示例
curl --location --request GET 'https://open.douyin.com/api/platform/v2/data_analysis/query_behavior_data/?end_time=1714896627&host_name=tg6LP21MQN&os=miPXgddnoc&version_type=0SkIa3z3yX&start_time=1714551027' \ --header 'content-type: application/json' \ --header 'access-token: 0801121846735352506a356a6' \
响应参数
Body展开全部子属性
err_msg必填String
错误信息
err_no必填Int32
错误码
log_id必填String
排查问题的logId
dataStruct
展开子属性
响应示例
正常响应示例异常响应示例
{ "err_no": 0, "err_msg": "success", "log_id": "xxx", "data": { "sum": { "active_user_num": 113, "new_user_num": 74, "total_user_num": 285227, "share_time": 8, "open_time": 190, "per_user_open_time": 1.6814, "per_user_stay_time": 349603, "avg_stay_time": 136095 }, "behaviors": [ { "time_type": 1, "time": "2022-12-26", "active_user_num": 113, "new_user_num": 74, "total_user_num": 285227, "share_time": 8, "open_time": 190, "per_user_open_time": 1.6814, "per_user_stay_time": 349603, "avg_stay_time": 136095 }, { "time_type": 1, "time": "2022-12-27", "active_user_num": 402, "new_user_num": 356, "total_user_num": 285583, "share_time": 24, "open_time": 563, "per_user_open_time": 1.4004, "per_user_stay_time": 90556, "avg_stay_time": 49672 } ] } }
错误码
HTTP 状态码 | 错误码 | 错误码描述 | 排查建议 |
---|---|---|---|
200 | -1 | 系统错误 | 建议重试,若多次重试失败,可向平台反馈该问题 |
200 | 11009 | 参数不合法或缺少参数 | 检查参数合法性,注意参数类型以及是否缺少必要参数 |
200 | 28001003 | access_token无效 | 请检查access_token |
200 | 28001007 | 必填字段缺失 | 请检查必填字段 |
200 | 28001008 | access_token过期 | 请刷新或重新授权access_token |