Query usage details (QueryUsageDetails)
Queries the resource usage statistics of the Raascall under the current account. Returns summary information such as call duration quota, used quota, remaining quota, usage rate, and number of seats for each billing period. Used for usage overview display.
Prerequisites
-
The SDK is installed.
-
An AccessKey is obtained and configured in environment variables. For more information, see Obtain an AccessKey and configure environment variables.
Request parameters
|
Name |
Type |
Required |
Description |
Example |
|
Action |
String |
Yes |
The operation that you want to perform. Set the value to QueryUsageDetails. |
QueryUsageDetails |
|
Version |
String |
Yes |
The API version number. Format: YYYY-MM-DD. Set the value to 2025-11-27. |
2025-11-27 |
|
StartDate |
String |
No |
The start date of the task. |
2024-01-01 |
|
EndDate |
String |
No |
The end date of the task. |
2024-01-31 |
|
UsageType |
String |
No |
CALL / SMS |
CALL |
|
TaskId |
Number |
No |
The task ID. |
1 |
|
Current |
Number |
No |
The current page number. |
1 |
|
Size |
Number |
No |
The number of entries per page. |
10 |
Response parameters
|
Name |
Type |
Description |
Example |
|
RequestId |
String |
The request ID. |
xxxx-xxxx-xxxx |
|
Success |
Boolean |
Indicates whether the request was successful. |
True |
|
Code |
String |
The error code. Empty when the request is successful. |
None |
|
Message |
String |
The error message or success message. |
Operation successful |
|
Total |
Long |
The total number of records. |
50 |
|
Current |
Long |
The current page number. |
1 |
|
Size |
Long |
The number of entries per page. |
10 |
|
Records |
Array |
The returned data, which includes fields such as DetailId, TaskId, TaskName, UsageType, CallCount, Duration, Cost, UsageDate, and GmtCreate. For more information, see the parameter description below. |
Examples
Python
import json
import os
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_tea_openapi.client import Client as OpenApiClient
from alibabacloud_tea_util import models as util_models
from alibabacloud_openapi_util.client import Client as OpenApiUtilClient
def main():
config = open_api_models.Config(
access_key_id=os.getenv("ACCESS_KEY_ID"),
access_key_secret=os.getenv("ACCESS_KEY_SECRET"),
)
config.endpoint = "thirdswaicall.aliyuncs.com"
config.protocol = "HTTPS"
client = OpenApiClient(config)
params = open_api_models.Params(
style="RPC",
version="2025-11-27",
action="QueryUsageDetails",
method="POST",
pathname="/",
protocol="HTTPS",
auth_type="AK",
req_body_type="json",
body_type="json",
)
body = {'StartDate': '2024-01-01', 'EndDate': '2024-01-31', 'Current': 1, 'Size': 10}
request = open_api_models.OpenApiRequest(query=OpenApiUtilClient.query(body))
runtime = util_models.RuntimeOptions(autoretry=True, max_attempts=3)
try:
resp = client.call_api(params, request, runtime)
print(json.dumps(resp.get("body", {}), ensure_ascii=False, indent=2))
except Exception as e:
print(f"调用失败: {e}")
if __name__ == "__main__":
main()
Java
import com.aliyun.teaopenapi.Client;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teaopenapi.models.OpenApiRequest;
import com.aliyun.teaopenapi.models.Params;
import com.aliyun.teautil.models.RuntimeOptions;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;
public class Demo {
public static void main(String[] args) throws Exception {
// 初始化配置
Config config = new Config()
.setAccessKeyId(System.getenv("ACCESS_KEY_ID"))
.setAccessKeySecret(System.getenv("ACCESS_KEY_SECRET"))
.setEndpoint("thirdswaicall.aliyuncs.com")
.setProtocol("HTTPS");
Client client = new Client(config);
// 设置 API 参数
Params params = new Params()
.setStyle("RPC")
.setVersion("2025-11-27")
.setAction("QueryUsageDetails")
.setMethod("POST")
.setPathname("/")
.setProtocol("HTTPS")
.setAuthType("AK")
.setReqBodyType("json")
.setBodyType("json");
// 构建请求参数
Map<String, Object> body = new HashMap<>();
body.put("StartDate", "2024-01-01");
body.put("EndDate", "2024-01-31");
body.put("Current", 1);
body.put("Size", 10);
OpenApiRequest request = new OpenApiRequest()
.setQuery(com.aliyun.openapiutil.Client.query(body));
// 设置运行时选项(自动重试)
RuntimeOptions runtime = new RuntimeOptions()
.setAutoretry(true)
.setMaxAttempts(3);
try {
// 调用 API
Map<String, ?> response = client.callApi(params, request, runtime);
Gson gson = new Gson();
System.out.println(gson.toJson(response.get("body")));
} catch (Exception e) {
System.err.println("调用失败: " + e.getMessage());
}
}
}
Sample response
{
"Success": true,
"Code": null,
"Message": "Operation successful",
"RequestId": "xxxx-xxxx-xxxx",
"Total": 50,
"Current": 1,
"Size": 10,
"Records": [
{
"DetailId": 1,
"TaskId": 1,
"TaskName": "Spring Festival promotion outbound call task",
"UsageType": "CALL",
"CallCount": 100,
"Duration": 500,
"Cost": 50.0,
"UsageDate": "2024-01-01",
"GmtCreate": "2025-01-10 10:00:00"
}
]
}
The specific results are contained in the Records node. The following table describes the parameters in the Records node.
|
Name |
Type |
Description |
Example |
|
DetailId |
Number |
The detail ID. |
1 |
|
TaskId |
Number |
The task ID. |
1 |
|
TaskName |
String |
The task name. |
Spring Festival promotion outbound call task |
|
UsageType |
String |
The usage type. |
CALL |
|
CallCount |
Number |
The number of calls. |
100 |
|
Duration |
Number |
The call duration in minutes. |
500 |
|
Cost |
Number |
The cost in yuan. |
50.0 |
|
UsageDate |
String |
The usage date. |
2024-01-01 |
|
GmtCreate |
String |
The creation time. |
2025-01-10 10:00:00 |
Error codes
If an error occurs, see Error codes for troubleshooting.