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: getUsageDetail
Mini Program can use this API to query the usage of purchased resource packs.
1. Call Method
HTTPS Call
GET https://api.weixin.qq.com/wxa/charge/usage/get?access_token=ACCESS_TOKEN
Cloud Call
- This API does not support cloud call.
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 | Example | Description |
|---|---|---|---|---|
| access_token | string | Yes | ACCESS_TOKEN | API call credential, you can use access_token, authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| spuId | string | Yes | Product SPU ID |
| offset | number | Yes | Pagination offset, starting from 0 |
| limit | number | Yes | Number of items per page, maximum 20 |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
| effectiveUse | string | Cumulative usage (64-bit integer), used for resource pack products |
| effectiveAll | string | Total resource volume (64-bit integer), used for resource pack products (deprecated) |
| all | string | Total available resource volume (64-bit integer), used for resource pack products. See Additional Notes for details |
| startServiceTime | number | Subscription start timestamp (in seconds), used for subscription products |
| endServiceTime | number | Subscription end timestamp (in seconds), used for subscription products |
| total | number | Total number of items in the usage details list |
| detailList | objarray | Usage details list |
Res.detailList(Array) Object Payload
Usage details list
| Parameter | Type | Description | Enum |
|---|---|---|---|
| pkgId | string | Resource pack ID | - |
| status | number | Resource pack status | Enum Values |
| startTime | number | Quota validity start timestamp (in seconds) | - |
| endTime | number | Quota validity end timestamp (in seconds) | - |
| all | string | Quota capacity (64-bit integer) | - |
| used | string | Used quota (64-bit integer) | - |
| spuId | string | SPU ID of the product from which the quota originated (64-bit integer) | - |
| skuId | string | SKU ID of the product from which the quota originated (64-bit integer) | - |
| source | number | Quota source | Enum Values |
4. Enum Information
Res.detailList(Array).status Enum
Resource pack status
| Enum Value | Description |
|---|---|
| 1 | Active |
| 2 | Inactive |
| 3 | Expired |
Res.detailList(Array).source Enum
Quota source
| Enum Value | Description |
|---|---|
| 1 | Trial quota |
| 2 | Paid purchase |
| 3 | Allocated by Service Provider |
| 4 | Other |
| 5 | Other |
5. Notes
Additional Notes
Specific meaning of the all field:
During the normal billing period for each paid capability: The total volume of currently effective resource packs (same as the original effectiveAll; the original field is deprecated).
During the pre-announcement billing period before formal billing starts for each paid capability: The total volume of currently effective resource packs and resource packs purchased but not yet effective.
6. Code Example
Request Example
GET https://api.weixin.qq.com/wxa/charge/usage/get?access_token=ACCESS_TOKEN&spuId=10000001&offset=0&limit=10
Response Example
{
"errcode": 0,
"all": "10",
"effectiveAll": "10",
"effectiveUse": "0",
"startServiceTime": 1669129510,
"endServiceTime": 1709450190,
"total": 2,
"detailList": [
{
"pkgId": "ZY2823973277692477440",
"startTime": 1677914190,
"endTime": 1709450190,
"used": "0",
"all": "4",
"status": 1,
"spuId": "10000057",
"skuId": "20000059"
},
{
"pkgId": "ZY2676590816357400576",
"startTime": 1669129510,
"endTime": 1700665510,
"used": "0",
"all": "6",
"status": 1,
"spuId": "10000057",
"skuId": "20000060"
}
]
}
7. 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 |
|---|---|
| 10120002 | Invalid parameter |
| 10120003 | The `limit` parameter value is too large. Reduce the value of `limit`. |
8. Applicable Scope
This API supports 「Mini Program」 account type calls. Other account types cannot call unless otherwise specified.