# 获取云开发数据
接口应在服务器端调用,详细说明参见服务端API。
本接口支持云调用。需开发者工具版本 >=
1.02.1904090
(最新稳定版下载),wx-server-sdk
>=0.4.0
# 接口说明
# 接口英文名
getCloudBaseStatistics
# 功能描述
该接口用于获取云开发数据。
# 调用方式
# HTTPS 调用
POST https://api.weixin.qq.com/tcb/getstatistics?access_token=ACCESS_TOKEN
# 云调用
出入参和HTTPS调用相同,调用方式可查看云调用说明文档
接口方法为: openapi.cloudbase.getStatistics
# 第三方调用
调用方式以及出入参和HTTPS相同,仅是调用的token不同
该接口所属的权限集id为:49、64
服务商获得其中之一权限集授权后,可通过使用authorizer_access_token代商家进行调用
# 请求参数
属性 | 类型 | 必填 | 说明 |
---|---|---|---|
access_token | string | 是 | 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token或者authorizer_access_token |
action | string | 是 | 获取动作,目前支持(smsMarketingOverviewData:短信营销概览数据;smsMarketingConversionData:短信营销转化数据;smsMarketingRealTimeData:短信营销实时数据) |
begin_date | number | 是 | 开始时间戳 |
end_date | number | 是 | 结束时间戳 |
page_limit | number | 是 | 分页 limit【action 取 smsMarketingOverviewData、smsMarketingConversionData 时必填】 |
page_offset | number | 是 | 分页 offset【action 取 smsMarketingOverviewData、smsMarketingConversionData 时必填】 |
# 返回参数
属性 | 类型 | 说明 | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data_column | array<object> | 数据列定义 | |||||||||||||||||
| |||||||||||||||||||
data_value | array<object> | 数据行 | |||||||||||||||||
| |||||||||||||||||||
total_num | number | 总行数 |
# 调用示例
示例说明: HTTPS请求示例
# 请求数据示例
{
"action":"smsMarketingOverviewData",
"begin_date": 1614182400,
"end_date": 1614268800,
"page_offset":0,
"page_limit":1000,
"condition":
{
"env_id":"xxx",
"activity_id":"xxx",
"by_channel_id":"0"
}
}
# 返回数据示例
{
"data_column":[
{
"col_id":"appid",
"col_name":"小程序id",
"col_data_type":"0"
},
{
"col_id":"env_id",
"col_name":"环境id",
"col_data_type":"0"
},
{
"col_id":"activity_id",
"col_name":"活动id",
"col_data_type":"0"
},
{
"col_id":"channel_id",
"col_name":"渠道",
"col_data_type":"0"
},
{
"col_id":"h5_open_uercnt",
"col_name":"h5打开人数",
"col_data_type":"1"
},
{
"col_id":"jump_wxapp_uercnt",
"col_name":"小程序跳转人数",
"col_data_type":"1"
},
{
"col_id":"sms_send_uercnt",
"col_name":"短信下发人数",
"col_data_type":"1"
},
{
"col_id":"sms_send_list",
"col_name":"下发记录数组",
"col_data_type":"0"
},
{
"col_id":"jump_wxapp_uercnt_percent",
"col_name":"跳转人数渠道占比",
"col_data_type":"2"
},
{
"col_id":"h5_open_uercnt_percent",
"col_name":"h5打开人数渠道占比",
"col_data_type":"2"
},
{
"col_id":"h5_sms_rate",
"col_name":"短信到h5转化率",
"col_data_type":"2"
},
{
"col_id":"jump_h5_rate",
"col_name":"h5到跳转转化率",
"col_data_type":"2"
}
],
"data_value":[
{
"data_value":[
"xxxxxxxxxxxxxxxxxx",
"wedcvfr",
"21ded5cb6001691405171ba161c603d1",
"_cms_sms_",
"5000",
"3000",
"10000",
"[task1:5000,task2:5000]",
"0.535714",
"0.625",
"0.5",
"0.6"
]
}
],
"total_num":1
}
示例说明: 云函数调用示例
# 请求数据示例
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.cloudbase.getStatistics({
"action": 'smsMarketingOverviewData',
"condition": {
"envId": 'xxx',
"activityId": 'xxx',
"byChannelId": '0'
},
"beginDate": 1614182400,
"endDate": 1614268800,
"pageOffset": 0,
"pageLimit": 1000
})
return result
} catch (err) {
return err
}
}
# 返回数据示例
{
"dataColumn": [
{
"colId": "appid",
"colName": "小程序id",
"colDataType": "0"
},
{
"colId": "env_id",
"colName": "环境id",
"colDataType": "0"
},
{
"colId": "activity_id",
"colName": "活动id",
"colDataType": "0"
},
{
"colId": "channel_id",
"colName": "渠道",
"colDataType": "0"
},
{
"colId": "h5_open_uercnt",
"colName": "h5打开人数",
"colDataType": "1"
},
{
"colId": "jump_wxapp_uercnt",
"colName": "小程序跳转人数",
"colDataType": "1"
},
{
"colId": "sms_send_uercnt",
"colName": "短信下发人数",
"colDataType": "1"
},
{
"colId": "sms_send_list",
"colName": "下发记录数组",
"colDataType": "0"
},
{
"colId": "jump_wxapp_uercnt_percent",
"colName": "跳转人数渠道占比",
"colDataType": "2"
},
{
"colId": "h5_open_uercnt_percent",
"colName": "h5打开人数渠道占比",
"colDataType": "2"
},
{
"colId": "h5_sms_rate",
"colName": "短信到h5转化率",
"colDataType": "2"
},
{
"colId": "jump_h5_rate",
"colName": "h5到跳转转化率",
"colDataType": "2"
}
],
"dataValue": [
{
"dataValue": [
"xxxxxxxxxxxxxxxxxx",
"wedcvfr",
"21ded5cb6001691405171ba161c603d1",
"_cms_sms_",
"5000",
"3000",
"10000",
"[task1:5000,task2:5000]",
"0.535714",
"0.625",
"0.5",
"0.6"
]
}
],
"totalNum": 1,
"errMsg": "openapi.cloudbase.getStatistics:ok"
}
# 错误码
错误码 | 错误码取值 | 解决方案 |
---|---|---|
10011 | 没有数据 |