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: getPerformance
This API is used to retrieve performance data.
1. Call Method
HTTPS Call
POST https://api.weixin.qq.com/wxaapi/log/get_performance?access_token=ACCESS_TOKEN
Encryption Support: This API supports secondary encryption and signature for service communication, which can effectively prevent data tampering and leakage. View Details
Cloud Call
-
Call Method: operation.getPerformance
-
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: 18
-
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 access_token, authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| cost_time_type | number | Yes | Optional values: 1 (total startup time), 2 (download time), 3 (initial rendering time) |
| default_start_time | number | Yes | Query start time |
| default_end_time | number | Yes | Query end time |
| device | string | Yes | System platform. Optional values: "@_all:" (all), 1 (iOS), 2 (Android) |
| is_download_code | string | Yes | Whether to download the code package. This parameter is only valid when type is 1. Optional values: "@_all:" (all), 1 (yes), 2 (no) |
| scene | string | Yes | Access source. This parameter is only valid when type is 1 or 2. Retrieve values via the getSceneList API. |
| networktype | string | Yes | Network environment. This parameter is only valid when type is 2. Optional values: "@_all:", wifi, 4g, 3g, 2g |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| default_time_data | string | Queried error data (JSON string, structured as the strbody described above) |
| compare_time_data | string | Comparison data |
4. Notes
strbody structure
| Attribute | Type | Description |
|---|---|---|
| ref_date | string | Date |
| cost_time_type | number | Same meaning as the cost_time_type parameter |
| cost_time | number | Duration (milliseconds) |
5. Code Example
5.1 HTTP request example
Request Example
{
"cost_time_type": 2,
"default_start_time": 1572339403,
"default_end_time": 1574931403,
"device": "@_all",
"networktype": "@_all",
"scene": "@_all",
"is_download_code": "@_all"
}
Response Example
{
"default_time_data": "{\"list\":[{\"ref_date\":\"20191029\",\"cost_time_type\":2,\"cost_time\":1533},{\"ref_date\":\"20191030\",\"cost_time_type\":2,\"cost_time\":1682}]}",
"compare_time_data": "",
"errcode": 0
}
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.operation.getPerformance({
"device": '@_all',
"networktype": '@_all',
"scene": '@_all',
"costTimeType": 2,
"defaultStartTime": 1572339403,
"defaultEndTime": 1574931403,
"isDownloadCode": '@_all'
})
return result
} catch (err) {
return err
}
}
Response 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.operation.getPerformance({
"errcode": 0,
"defaultTimeData": '{\'list\":[{\"ref_date\":\"20191029\",\"cost_time_type\":2,\"cost_time\":1533},{\"ref_date\":\"20191030\",\"cost_time_type\":2,\"cost_time\":1682}]}",
"compareTimeData": ''
})
return result
} catch (err) {
return err
}
}
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 |
|---|---|---|
| -1 | system error | The system is busy. Please try again later. |
| 40001 | invalid credential access_token isinvalid or not latest | The AppSecret is incorrect when retrieving access_token, or the access_token is invalid. Developers should verify the correctness of the AppSecret or ensure they are calling the API for the appropriate Official Account. |
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.