DescribeInstances

Last updated: 2020-09-17 17:54:19

1. API Description

Domain name for API request: cvm.tencentcloudapi.com.

This API is used to query the details of instances.

  • You can filter the query results with the instance ID, name, or billing method. See Filter for more information.
  • If no parameter is defined, a certain number of instances under the current account will be returned. The number is specified by Limit and is 20 by default.

A maximum of 40 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: cvm.ap-shanghai-fsi.tencentcloudapi.com

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: DescribeInstances.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
InstanceIds.N No Array of String Query by instance ID(s). For example, instance ID: ins-xxxxxxxx. For the specific format, refer to section Ids.N of the API Introduction. You can query up to 100 instances in each request. However, InstanceIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filters.
  • zone - String - Optional - Filter results by availability zone.
  • project-id - Integer - Optional - Filter results by project ID. You can call DescribeProject or log in to the console to view the list of existing projects. You can also create a new project by calling AddProject.
  • host-id - String - Optional - Filter results by CDH ID. CDH ID format: host-xxxxxxxx.

  • vpc-id - String - Optional - Filter results by VPC ID. VPC ID format: vpc-xxxxxxxx.
  • subnet-id - String - Optional - Filter results by subnet ID. Subnet ID format: subnet-xxxxxxxx.

  • instance-id - String - Optional - Filter results by instance ID. Instance ID format: ins-xxxxxxxx.
    security-group-id - String - Optional - Filter results by security group ID. Security group ID format: sg-8jlk3f3r.
    instance-name - String - Optional - Filter results by instance name.
    instance-charge-type - String - Optional - Filter results by instance billing method. POSTPAID_BY_HOUR: pay-as-you-go | CDHPAID: you are only billed for CDH instances, not the CVMs running on the CDH instances.
    private-ip-address - String - Optional - Filter results by the private IP address of the instance's primary ENI.
    public-ip-address - String - Optional - Filter results by the public IP address of the instance's primary ENI, including the IP addresses automatically assigned during the instance creation and the EIPs manually associated after the instance creation.
  • tag-key - String - Optional - Filter results by tag key.

  • tag-value - String - Optional - Filter results by tag value.
  • tag:tag-key - String - Optional - Filter results by tag key-value pair. Replace tag-key with specific tag keys, as shown in example 2.

  • Each request can have up to 10 Filters and 5 Filters.Values. You cannot specify InstanceIds and Filters at the same time.
    Offset No Integer Offset; default value: 0. For more information on Offset, see the corresponding section in API Introduction.
    Limit No Integer Number of results returned; default value: 20; maximum: 100. For more information on Limit, see the corresponding section in API Introduction.

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer Number of instances meeting the filtering conditions.
    InstanceSet Array of Instance Detailed instance information.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Querying a list of instances

    This example shows you how to query instances in Guangzhou Zone 1 or Guangzhou Zone 2 and return up to one result.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=DescribeInstances
    &Filters.0.Name=zone
    &Filters.0.Values.0=ap-guangzhou-1
    &Filters.0.Values.1=ap-guangzhou-2
    &Offset=0
    &Limit=1
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "InstanceSet": [
          {
            "RenewFlag": "null",
            "Uuid": "68b510db-b4c1-4630-a62b-73d0c7c970f9",
            "InstanceState": "RUNNING",
            "LatestOperationState": "SUCCESS",
            "OsName": "CentOS 7.6 64bit",
            "CreatedTime": "2020-03-10T02:43:51Z",
            "RestrictState": "NORMAL",
            "ExpiredTime": "2020-04-10T02:47:36Z",
            "DisasterRecoverGroupId": "",
            "Memory": 1,
            "IPv6Addresses": null,
            "CPU": 1,
            "CamRoleName": "",
            "PublicIpAddresses": [
              "123.207.11.190"
            ],
            "Tags": [],
            "InstanceId": "ins-9bxebleo",
            "PhysicalPosition": {
              "PosId": "48C7C7A369705E6F3FE45126D39F2915",
              "SwitchId": "A5A6ACC7CB106C396E3CF7477C883FB4",
              "RackId": "DFE8AC9E645197818BE0B55AEAF0DD17"
            },
            "ImageId": "img-9qabwvbn",
            "StopChargingMode": "NOT_APPLICABLE",
            "InstanceChargeType": "PREPAID",
            "InstanceType": "S1.SMALL1",
            "SystemDisk": {
              "DiskSize": 50,
              "DiskId": "disk-nucurerk",
              "DiskType": "CLOUD_PREMIUM"
            },
            "Placement": {
              "ProjectId": 1174660,
              "HostId": null,
              "Zone": "ap-guangzhou-2"
            },
            "ExtraAttribute": {
              "MWait": "OFF"
            },
            "PrivateIpAddresses": [
              "172.16.32.78"
            ],
            "LoginSettings": {
              "KeyIds": null
            },
            "SecurityGroupIds": [
              "sg-p1ezv4wz"
            ],
            "InstanceName": "Test instance",
            "DataDisks": null,
            "IsolatedSource": "NOTISOLATED",
            "VirtualPrivateCloud": {
              "SubnetId": "subnet-a2676p0e",
              "AsVpcGateway": false,
              "VpcId": "vpc-g7wzcv7n"
            },
            "LatestOperationRequestId": "3554eb5b-1cfa-471a-ae76-dc436c9d43e8",
            "InternetAccessible": {
              "InternetMaxBandwidthOut": 1,
              "InternetChargeType": "BANDWIDTH_PREPAID"
            },
            "LatestOperation": "RenewInstances"
          }
        ],
        "TotalCount": 2,
        "RequestId": "62DDFFC6-FDB5-44F7-20A6-59152E3D129A"
      }
    }

    Example2 Querying the last operation and status of an instance

    This example shows you how to use DescribeInstances to query an instance after using StopInstances to stop it. You will see that the value of LatestOperation is StopInstances and LatestOperationState is OPERATING.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=DescribeInstances
    &Filters.0.Name=zone
    &Filters.0.Values.0=ap-guangzhou-1
    &Filters.0.Values.1=ap-guangzhou-2
    &Offset=0
    &Limit=1
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "InstanceSet": [
          {
            "RenewFlag": "null",
            "Uuid": "68b510db-b4c1-4630-a62b-73d0c7c970f9",
            "InstanceState": "STOPPING",
            "LatestOperationState": "OPERATING",
            "OsName": "CentOS 7.6 64bit",
            "CreatedTime": "2020-03-10T02:43:51Z",
            "RestrictState": "NORMAL",
            "ExpiredTime": "2020-04-10T02:47:36Z",
            "DisasterRecoverGroupId": "",
            "Memory": 1,
            "IPv6Addresses": null,
            "CPU": 1,
            "CamRoleName": "",
            "PublicIpAddresses": [
              "123.207.11.190"
            ],
            "Tags": [],
            "InstanceId": "ins-9bxebleo",
            "PhysicalPosition": {
              "PosId": "48C7C7A369705E6F3FE45126D39F2915",
              "SwitchId": "A5A6ACC7CB106C396E3CF7477C883FB4",
              "RackId": "DFE8AC9E645197818BE0B55AEAF0DD17"
            },
            "ImageId": "img-9qabwvbn",
            "StopChargingMode": "NOT_APPLICABLE",
            "InstanceChargeType": "PREPAID",
            "InstanceType": "S1.SMALL1",
            "SystemDisk": {
              "DiskSize": 50,
              "DiskId": "disk-nucurerk",
              "DiskType": "CLOUD_PREMIUM"
            },
            "Placement": {
              "ProjectId": 1174660,
              "HostId": null,
              "Zone": "ap-guangzhou-2"
            },
            "ExtraAttribute": {
              "MWait": "OFF"
            },
            "PrivateIpAddresses": [
              "172.16.32.78"
            ],
            "LoginSettings": {
              "KeyIds": null
            },
            "SecurityGroupIds": [
              "sg-p1ezv4wz"
            ],
            "InstanceName": "Test instance",
            "DataDisks": null,
            "IsolatedSource": "NOTISOLATED",
            "VirtualPrivateCloud": {
              "SubnetId": "subnet-a2676p0e",
              "AsVpcGateway": false,
              "VpcId": "vpc-g7wzcv7n"
            },
            "LatestOperationRequestId": "2f8decef-78b2-4e20-bcfe-7a5112658a05",
            "InternetAccessible": {
              "InternetMaxBandwidthOut": 1,
              "InternetChargeType": "BANDWIDTH_PREPAID"
            },
            "LatestOperation": "StopInstances"
          }
        ],
        "TotalCount": 2,
        "RequestId": "62DDFFC6-FDB5-44F7-20A6-59152E3D129A"
      }
    }

    Example3 Querying instances associated with a tag

    This example shows you how to query a list of instances associated with the tag city:shenzhen.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=DescribeInstances
    &Filters.0.Name=tag:city
    &Filters.0.Values.0=shenzhen
    &Offset=0
    &Limit=1
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "InstanceSet": [
          {
            "RenewFlag": "NOTIFY_AND_MANUAL_RENEW",
            "Uuid": "68b510db-b4c1-4630-a62b-73d0c7c970f9",
            "InstanceState": "RUNNING",
            "LatestOperationState": "SUCCESS",
            "OsName": "CentOS 7.6 64bit",
            "CreatedTime": "2020-03-10T02:43:51Z",
            "RestrictState": "NORMAL",
            "ExpiredTime": "2020-04-10T02:47:36Z",
            "DisasterRecoverGroupId": "",
            "Memory": 1,
            "IPv6Addresses": null,
            "CPU": 1,
            "CamRoleName": "",
            "PublicIpAddresses": [
              "123.207.11.190"
            ],
            "Tags": [
              {
                "tagKey": "city",
                "Value": "shenzhen",
                "tagValue": "shenzhen",
                "Key": "city"
              }
            ],
            "InstanceId": "ins-9bxebleo",
            "PhysicalPosition": {
              "PosId": "48C7C7A369705E6F3FE45126D39F2915",
              "SwitchId": "A5A6ACC7CB106C396E3CF7477C883FB4",
              "RackId": "DFE8AC9E645197818BE0B55AEAF0DD17"
            },
            "ImageId": "img-9qabwvbn",
            "StopChargingMode": "NOT_APPLICABLE",
            "InstanceChargeType": "PREPAID",
            "InstanceType": "S1.SMALL1",
            "SystemDisk": {
              "DiskSize": 50,
              "DiskId": "disk-nucurerk",
              "DiskType": "CLOUD_PREMIUM"
            },
            "Placement": {
              "ProjectId": 1174660,
              "HostId": null,
              "Zone": "ap-guangzhou-2"
            },
            "ExtraAttribute": {
              "MWait": "OFF"
            },
            "PrivateIpAddresses": [
              "172.16.32.78"
            ],
            "LoginSettings": {
              "KeyIds": null
            },
            "SecurityGroupIds": [
              "sg-p1ezv4wz"
            ],
            "InstanceName": "Test instance",
            "DataDisks": null,
            "IsolatedSource": "NOTISOLATED",
            "VirtualPrivateCloud": {
              "SubnetId": "subnet-a2676p0e",
              "AsVpcGateway": false,
              "VpcId": "vpc-g7wzcv7n"
            },
            "LatestOperationRequestId": "3554eb5b-1cfa-471a-ae76-dc436c9d43e8",
            "InternetAccessible": {
              "InternetMaxBandwidthOut": 1,
              "InternetChargeType": "BANDWIDTH_PREPAID"
            },
            "LatestOperation": "RenewInstances"
          }
        ],
        "TotalCount": 1,
        "RequestId": "62DDFFC6-FDB5-44F7-20A6-59152E3D129A"
      }
    }

    5. Developer Resources

    API Explorer

    This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.IllegalTagKey The tag key contains invalid characters.
    InternalServerError Internal error.
    InvalidFilter Invalid filter.
    InvalidFilterValue.LimitExceeded Filter
    InvalidHostId.Malformed Invalid CDH ID. The specified CDH ID has an invalid format. For example, host-1122 has an invalid ID length.
    InvalidInstanceId.Malformed Invalid instance ID. The specified instance ID has an invalid format. For example, ins-1122 has an invalid ID length.
    InvalidParameter Invalid parameter. The parameter does not meet the requirements or is not supported.
    InvalidParameterValue Invalid parameter value: parameter value is in the wrong format or is not supported.
    InvalidParameterValue.InvalidIpFormat Invalid IP address.
    InvalidParameterValue.LimitExceeded The number of parameter values exceeds the limit.
    InvalidParameterValue.SubnetIdMalformed Invalid subnet ID. Provide a subnet ID in the format of subnet-xxxxxxxx, where the letter x refers to lowercase characters or number.
    InvalidSecurityGroupId.NotFound The specified security group ID does not exist.
    InvalidSgId.Malformed The specified security group ID is in the wrong format. For example, sg-ide32 has an invalid instance ID length.
    InvalidZone.MismatchRegion The specified zone does not exist.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help