GetIqsUsage API reference
This topic describes the parameters of the GetIqsUsage operation and provides usage examples.
Description
This operation allows you to query your daily usage data on a T+1 basis. Data for the previous day becomes available after 10:00 AM.
API reference
Request parameters
Parameter | Type | Required | Default | Description | Example |
startDate | string | Yes | - | The start date for the usage query (inclusive). The date must be in the YYYYMMDD format and within the last 60 days. | 20250612 |
endDate | string | Yes | - | The end date for the usage query (inclusive). The date must be in the YYYYMMDD format and within the last 60 days. | 20250612 |
callerId | String | No | - | The identifier of the caller to query. This can be the ID of an Alibaba Cloud sub-account or the identifier associated with an API key. | 138608930460**** |
Response parameters
Field | Type | Nullable | Description | Example | |
requestId | string | No | The ID of the request. You can provide this ID for troubleshooting. | 35E5608A-A737-2038-****-D9D34C6BFD9E | |
records | date | string | No | The metering date. | 20250612 |
mainAccountId | string | No | The main account ID. | 128608930******0 | |
subAccountId | string | No | The ID of the sub-account that made the request, such as a RAM user or an | 2193843763***9272 | |
api | string | No | The name of the API. | UnifiedSearch | |
engineType | string | No | The engine type. Valid values:
| Generic | |
billingQps | int32 | Yes | The queries per second (QPS) used for tiered pricing. | 30 | |
ladderType | string | Yes | The matched pricing tier. Valid values:
| 1001 | |
valueAddedSummary | int32 | No | Usage of the value-added package for the summary feature. | 293480 | |
valueAddedAdvanced | int32 | No | Usage of the value-added package for advanced search. | 23324 | |
totalCalls | int32 | No | The total number of calls. | 293482 | |
successCalls | int32 | No | The number of successful calls. | 293480 | |
failedCalls | int32 | No | The number of failed calls. | 2 | |
Examples
Example request
https://*/iqs/usage?endDate=20250723&startDate=20250701Example response
{ "requestId": "929a2db4-aa7e-4b62-8291-f08fb17f6a75", "records": [ { "date": "20250716", "mainAccountId": "138608930******0", "subAccountId": "138608930******0", "api": "UnifiedSearch", "engineType": "Generic", "billingQps": 30, "ladderType": "1001", "totalCalls": 5, "successCalls": 5, "failedCalls": 0, "valueAddedSummary": 5, "valueAddedAdvanced": 0 }, { "date": "20250716", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "GenericAdvanced", "billingQps": 30, "ladderType": "1001", "totalCalls": 5, "successCalls": 5, "failedCalls": 0, "valueAddedSummary": 5, "valueAddedAdvanced": 5 }, { "date": "20250718", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "Generic", "billingQps": 30, "ladderType": "1001", "totalCalls": 4, "successCalls": 4, "failedCalls": 0, "valueAddedSummary": 2, "valueAddedAdvanced": 0 }, { "date": "20250718", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "GenericAdvanced", "billingQps": 30, "ladderType": "1001", "totalCalls": 4, "successCalls": 4, "failedCalls": 0, "valueAddedSummary": 2, "valueAddedAdvanced": 4 }, { "date": "20250721", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "GenericAdvanced", "billingQps": 30, "ladderType": "1001", "totalCalls": 5, "successCalls": 5, "failedCalls": 0, "valueAddedSummary": 5, "valueAddedAdvanced": 5 }, { "date": "20250722", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "Generic", "billingQps": 30, "ladderType": "1001", "totalCalls": 9, "successCalls": 9, "failedCalls": 0, "valueAddedSummary": 9, "valueAddedAdvanced": 0 }, { "date": "20250722", "mainAccountId": "138608930*******0", "subAccountId": "138608930*******0", "api": "UnifiedSearch", "engineType": "GenericAdvanced", "billingQps": 30, "ladderType": "1001", "totalCalls": 3, "successCalls": 3, "failedCalls": 0, "valueAddedSummary": 3, "valueAddedAdvanced": 3 } ] }
Calling the API
Using SDKs
You can call this API operation using an Alibaba Cloud SDK. You must authenticate your request with an AccessKey pair.
Python SDK
Prerequisites
You must have Python 3.8 or later installed.
Install the SDK
pip install alibabacloud_iqs20241111==1.6.4Sample code
Synchronous call
import os from Tea.exceptions import TeaException from alibabacloud_iqs20241111 import models from alibabacloud_iqs20241111.client import Client from alibabacloud_tea_openapi import models as open_api_models class Sample: def __init__(self): pass @staticmethod def create_client() -> Client: config = open_api_models.Config( # Replace with your AccessKey ID and AccessKey secret. # We recommend that you load your credentials from environment variables for improved security. access_key_id='$YOUR_ACCESS_KEY', access_key_secret='$YOUR_ACCESS_SECRET' ) config.endpoint = f'iqs.cn-zhangjiakou.aliyuncs.com' return Client(config) @staticmethod def main() -> None: client = Sample.create_client() get_iqs_usage_request = models.GetIqsUsageRequest( start_date='20250701', end_date='20250723' ) try: response = client.get_iqs_usage(get_iqs_usage_request) print(f"api success, size :{len(response.body.records)}") if len(response.body.records) > 0: print(f"records:{response.body.records[0]}") for index, item in enumerate(response.body.records): print(f"{index}. {'-' * 20}") print(f"api:{item.api}") print(f"date:{item.date}") print(f"engineType:{item.engine_type}") print(f"mainAccountId:{item.main_account_id}") print(f"subAccountId:{item.sub_account_id}") print(f"totalCalls:{item.total_calls}") print(f"successCalls:{item.success_calls}") print(f"valueAddedSummary:{item.value_added_summary}") print(f"valueAddedAdvanced:{item.value_added_advanced}") except TeaException as e: code = e.code request_id = e.data.get("requestId") message = e.data.get("message") print(f"api exception, requestId:{request_id}, code:{code}, message:{message}") if __name__ == '__main__': Sample.main()Asynchronous call
import asyncio import os import time from Tea.exceptions import TeaException from alibabacloud_iqs20241111 import models from alibabacloud_iqs20241111.client import Client from alibabacloud_tea_openapi import models as open_api_models class Sample: def __init__(self): pass @staticmethod def create_client() -> Client: config = open_api_models.Config( # This example reads the AccessKey ID and AccessKey secret from environment variables. access_key_id=os.environ.get('ACCESS_KEY'), access_key_secret=os.environ.get('ACCESS_SECRET') ) config.endpoint = f'iqs.cn-zhangjiakou.aliyuncs.com' return Client(config) @staticmethod async def main_async() -> None: start = time.time() client = Sample.create_client() get_iqs_usage_request = models.GetIqsUsageRequest( start_date='20250701', end_date='20250723' ) try: # Use the asynchronous method. response = await client.get_iqs_usage_async(get_iqs_usage_request) print(f"api success, size :{len(response.body.records)}") if len(response.body.records) > 0: print(f"records:{response.body.records[0]}") for index, item in enumerate(response.body.records): print(f"{index}. {'-' * 20}") print(f"api:{item.api}") print(f"date:{item.date}") print(f"engineType:{item.engine_type}") print(f"mainAccountId:{item.main_account_id}") print(f"subAccountId:{item.sub_account_id}") print(f"totalCalls:{item.total_calls}") print(f"successCalls:{item.success_calls}") print(f"valueAddedSummary:{item.value_added_summary}") print(f"valueAddedAdvanced:{item.value_added_advanced}") except TeaException as e: code = e.code request_id = e.data.get("requestId") message = e.data.get("message") print(f"api exception, requestId:{request_id}, code:{code}, message:{message}") if __name__ == '__main__': asyncio.run(Sample.main_async())
Java SDK
Prerequisites
You must have Java 8 or later installed.
Maven dependency
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>iqs20241111</artifactId>
<version>1.6.4</version>
</dependency>Sample code
package com.aliyun.iqs;
import com.aliyun.iqs20241111.Client;
import com.aliyun.iqs20241111.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* @author zj-407802
* @date 2025/7/25 10:03
* @desc
**/
public class GetIqsUsageExample {
public static void main(String[] args) throws Exception {
Client client = initClient();
invoke(client, "20250701", "20250723");
}
private static Client initClient() throws Exception {
// Replace with your AccessKey ID and AccessKey secret.
// We recommend that you load your credentials from environment variables for improved security.
String accessKeyId = "$YOUR_ACCESS_KEY";
String accessKeySecret = "$YOUR_ACCESS_SECRET";
Config config = new Config()
.setAccessKeyId(accessKeyId)
.setAccessKeySecret(accessKeySecret);
config.setEndpoint("iqs.cn-zhangjiakou.aliyuncs.com");
return new Client(config);
}
private static void invoke(Client client, String startDate, String endDate) {
GetIqsUsageRequest request = new GetIqsUsageRequest();
request.setStartDate(startDate);
request.setEndDate(endDate);
try {
GetIqsUsageResponse response = client.getIqsUsage(request);
GetIqsUsageResult body = response.getBody();
printOutput(body);
} catch (Exception e) {
e.printStackTrace();
}
}
private static void printOutput(GetIqsUsageResult output) {
// Create a Gson instance with pretty printing using GsonBuilder.
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.create();
// Print the formatted JSON.
String prettyJson = gson.toJson(output);
System.out.println(prettyJson);
}
}
Go SDK
Prerequisites
You must have Go 1.10.x or later installed.
Install the SDK
require (
github.com/alibabacloud-go/iqs-20241111 v1.6.4
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10
)Sample code
package main
import (
"fmt"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
iqs20241111 "github.com/alibabacloud-go/iqs-20241111/client"
util "github.com/alibabacloud-go/tea-utils/v2/service"
"github.com/alibabacloud-go/tea/tea"
"log"
)
const endpointURL = "iqs.cn-zhangjiakou.aliyuncs.com"
func createClient() (*iqs20241111.Client, error) {
// Replace with your AccessKey ID and AccessKey secret.
accessKeyID := "YOUR_ACCESS_KEY"
accessKeySecret := "YOUR_ACCESS_SECRET"
if accessKeyID == "" || accessKeySecret == "" {
return nil, fmt.Errorf("ACCESS_KEY or ACCESS_SECRET environment variable is not set")
}
config := &openapi.Config{
AccessKeyId: tea.String(accessKeyID),
AccessKeySecret: tea.String(accessKeySecret),
Endpoint: tea.String(endpointURL),
}
return iqs20241111.NewClient(config)
}
func runGetIqsUsage(client *iqs20241111.Client) error {
request := &iqs20241111.GetIqsUsageRequest{
StartDate: tea.String("20250610"),
EndDate: tea.String("20250723"),
}
runtime := &util.RuntimeOptions{}
resp, err := client.GetIqsUsageWithOptions(request, nil, runtime)
if err != nil {
return fmt.Errorf("GetIqsUsage failed: %w", err)
}
fmt.Printf("response: %s\n", resp.Body)
return nil
}
func main() {
client, err := createClient()
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
if err := runGetIqsUsage(client); err != nil {
log.Fatalf("Error running GetIqsUsage: %v", err)
}
}
}