Query call volume API

Updated at:

This topic describes the parameters and usage of the GetIqsUsage API operation.

API description

This API operation queries the daily usage of the Information Query Service on a T+1 basis. You can query data for the previous day after 10:00 AM.

API definition

Request parameters

Parameter

Type

Required

Default value

Description

Sample value

startDate

string

Yes

-

The start date for the usage query. The date is inclusive. The start date must be within the last 60 days.

20250612

endDate

string

Yes

-

The end date for the usage query. The date is inclusive. The end date must be within the last 60 days.

20250612

callerId

String

No

-

The ID of the Alibaba Cloud RAM user or the caller identity of the API Key to query.

138608930460****

Response parameters

Field

Type

Nullable

Description

Example

requestId

string

This field is required.

The request ID. Provide this ID for troubleshooting.

35E5608A-A737-2038-****-D9D34C6BFD9E

records

date

string

This field is required.

The metering date.

20250612

mainAccountId

string

This field is required.

The ID of the root account.

128608930******0

subAccountId

string

This field is required.

The caller's sub-account, which can be a RAM user or an api_key identifier.

2193843763***9272

api

string

This field is required.

The API name.

UnifiedSearch

engineType

string

This field is required.

The engine type. Valid values:

  • Generic: Standard Edition search.

  • GenericAdvanced: Enhanced search.

  • LiteAdvanced: Lightweight enhanced search.

Generic

billingQps

int32

Nullable

The tiered billing QPS.

30

ladderType

string

Nullable

The matched billing tier. Valid values:

  • 1001: Tier 1.

  • 1002: Tier 2.

  • 1003: Tier 3.

  • 1004: Tier 4.

1001

valueAddedSummary

int32

This field is required.

The usage of the value-added package for enabling summaries.

293,480 times

valueAddedAdvanced

int32

The value cannot be empty.

You can call the interface to increase the usage of the value-added package.

23,324 views

totalCalls

int32

This field is required.

The total number of calls.

293482

successCalls

int32

The field cannot be empty.

The number of successful calls.

293480

failedCalls

int32

This field cannot be empty.

The number of failed calls.

Twice

Examples

  • Request parameters

    https://*/iqs/usage?endDate=20250723&startDate=20250701
  • Response parameters

    {
      "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
        }
      ]
    }

API invocation

SDK calls

You can use an AccessKey pair for authentication and an Alibaba Cloud SDK to make API calls.

Python SDK

Prerequisites

Make sure that you have Python 3.8 or later installed.

Install the SDK
pip install alibabacloud_iqs20241111==1.6.4
Sample code
  • Synchronous invocation

    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 loading them from environment variables.
               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 call successful. 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 invocation

    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(
                # The AccessKey ID and AccessKey secret are loaded 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 an asynchronous method call.
                response = await client.get_iqs_usage_async(get_iqs_usage_request)
                print(f"API call successful. 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

Make sure that you 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 loading them from environment variables.
        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) {
        // Use GsonBuilder to create a formatted Gson instance.
        Gson gson = new GsonBuilder()
                .setPrettyPrinting()
                .disableHtmlEscaping()
                .create();

        // Print the formatted JSON.
        String prettyJson = gson.toJson(output);
        System.out.println(prettyJson);
    }
}

Go SDK

Prerequisites

Make sure that your Go environment is 1.10.x or later.

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)
	}
}

}