This API should be called on the server side and cannot be called directly on the client side (Mini Program, web page, APP, etc.). For details, please refer to API Call Guide.
API English Name: getCloudBaseStatistics
This API is used to retrieve Cloud Development data.
1. Call Method
HTTPS Call
POST https://api.weixin.qq.com/tcb/getstatistics?access_token=ACCESS_TOKEN
Cloud Call
-
Call Method: cloudbase.getStatistics
-
Input and output parameters are the same as HTTPS call. For call method, please refer to Cloud Call documentation.
Third-party Call
-
This API supports third-party platforms on behalf of Merchant call.
-
The permission set ID of this API is: 49
-
After the service provider obtains one of the permission set authorizations, it can use authorizer_access_token to call on behalf of Merchant, for details please refer to Third-party Call documentation.
2. Request Parameters
Query Parameters Query String Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| access_token | string | Yes | API call credential, you can use authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| action | string | Yes | The retrieval action. Currently supported values: `smsMarketingOverviewData` (SMS Marketing Overview Data), `smsMarketingConversionData` (SMS Marketing Conversion Data), and `smsMarketingRealTimeData` (SMS Marketing Real-Time Data). |
| begin_date | number | Yes | Start timestamp |
| end_date | number | Yes | End timestamp |
| page_limit | number | Yes | Pagination limit [Required when `action` is set to `smsMarketingOverviewData` or `smsMarketingConversionData`] |
| page_offset | number | Yes | Pagination offset [Required when `action` is set to `smsMarketingOverviewData` or `smsMarketingConversionData`] |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| data_column | objarray | Data column definitions |
| data_value | objarray | Data rows |
| total_num | number | Total number of rows |
Res.data_column(Array) Object Payload
Data column definitions
| Parameter | Type | Description |
|---|---|---|
| col_id | string | Column ID |
| col_name | string | Column name |
| col_data_type | string | Data type (0: string; 1: number; 2: double) |
Res.data_value(Array) Object Payload
Data rows
| Parameter | Type | Description |
|---|---|---|
| data_value | array | Data values |
4. Notes
No special notes for this API
5. Code Example
5.1 HTTPS Request Example
Request Example
{
"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"
}
}
Response Example
{
"data_column": [
{
"col_id": "appid",
"col_name": " Mini Program id",
"col_data_type": "0"
},
{
"col_id": "env_id",
"col_name": "Environment ID",
"col_data_type": "0"
},
{
"col_id": "activity_id",
"col_name": "Activity ID",
"col_data_type": "0"
},
{
"col_id": "channel_id",
"col_name": "Channel",
"col_data_type": "0"
},
{
"col_id": "h5_open_uercnt",
"col_name": "Number of H5 Users Opened",
"col_data_type": "1"
},
{
"col_id": "jump_wxapp_uercnt",
"col_name": " Mini Program Jump Users Count",
"col_data_type": "1"
},
{
"col_id": "sms_send_uercnt",
"col_name": "Number of SMS Recipients",
"col_data_type": "1"
},
{
"col_id": "sms_send_list",
"col_name": "Delivery Record Array",
"col_data_type": "0"
},
{
"col_id": "jump_wxapp_uercnt_percent",
"col_name": "Jump User Ratio by Channel",
"col_data_type": "2"
},
{
"col_id": "h5_open_uercnt_percent",
"col_name": "H5 Open User Ratio by Channel",
"col_data_type": "2"
},
{
"col_id": "h5_sms_rate",
"col_name": "SMS to H5 Conversion Rate",
"col_data_type": "2"
},
{
"col_id": "jump_h5_rate",
"col_name": "H5 to Jump Conversion Rate",
"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
}
5.2 Cloud Function Call Example
Request Example
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
}
}
Response Example
{
"dataColumn": [
{
"colId": "appid",
"colName": " Mini Program id",
"colDataType": "0"
},
{
"colId": "env_id",
"colName": "Environment ID",
"colDataType": "0"
},
{
"colId": "activity_id",
"colName": "Activity ID",
"colDataType": "0"
},
{
"colId": "channel_id",
"colName": "Channel",
"colDataType": "0"
},
{
"colId": "h5_open_uercnt",
"colName": "Number of H5 Users Opened",
"colDataType": "1"
},
{
"colId": "jump_wxapp_uercnt",
"colName": " Mini Program Jump Users Count",
"colDataType": "1"
},
{
"colId": "sms_send_uercnt",
"colName": "Number of SMS Recipients",
"colDataType": "1"
},
{
"colId": "sms_send_list",
"colName": "Delivery Record Array",
"colDataType": "0"
},
{
"colId": "jump_wxapp_uercnt_percent",
"colName": "Jump User Ratio by Channel",
"colDataType": "2"
},
{
"colId": "h5_open_uercnt_percent",
"colName": "H5 Open User Ratio by Channel",
"colDataType": "2"
},
{
"colId": "h5_sms_rate",
"colName": "SMS to H5 Conversion Rate",
"colDataType": "2"
},
{
"colId": "jump_h5_rate",
"colName": "H5 to Jump Conversion Rate",
"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"
}
6. Error Codes
The following is the error code list of this API, other error codes can refer to Common Error Codes; When encountering errors in calling the API, you can use the official API Diagnostic Tool to assist in locating and analyzing problems.
| Error Code | Error Description | Solution |
|---|---|---|
| 10011 | No data available |
7. Applicable Scope
| Mini Program | Mini Game |
|---|---|
| ✔ | ✔ |
- ✔:This account type can call this API。
- Other account types not explicitly declared cannot call this API unless otherwise specified.