DescribeInstances

Last updated: 2020-01-17 10:24:59

PDF

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

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 Instance ID(s) in the format of ins-xxxxxxxx. For more information on the format of this parameter, see the id.N section of API Introduction. The maximum number of instances in each request is 100. You cannot specify InstanceIds and Filters 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

    Input Example

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

    Output Example

    {
      "Response": {
        "TotalCount": 2,
        "InstanceSet": [
          {
            "Placement": {
              "Zone": "ap-shanghai-1",
              "HostId": "",
              "ProjectId": 0
            },
            "InstanceId": "ins-r8hr2upy",
            "InstanceType": "S5.16XLARGE256",
            "CPU": 64,
            "Memory": 256,
            "InstanceName": "test",
            "InstanceChargeType": "PREPAID",
            "SystemDisk": {
              "DiskType": "CLOUD_PREMIUM",
              "DiskId": "disk-4rnslbwq",
              "DiskSize": 50
            },
            "DataDisks": [
              {
                "DiskType": "CLOUD_PREMIUM",
                "DiskId": "disk-4rnslb35",
                "DiskSize": 50
              }
            ],
            "PrivateIpAddresses": [
              "10.104.37.58"
            ],
            "PublicIpAddresses": [
              "123.207.32.83"
            ],
            "InternetAccessible": {
              "InternetMaxBandwidthOut": 2,
              "InternetChargeType": "BANDWIDTH_PREPAID"
            },
            "VirtualPrivateCloud": {
              "VpcId": "vpc-4e78ea76",
              "SubnetId": "subnet-6d7kj98i",
              "AsVpcGateway": "TRUE"
            },
            "ImageId": "img-0vbqvzfn",
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "CreatedTime": "2016-12-02T00:22:40Z",
            "ExpiredTime": "2017-01-02T00:22:48Z"
          }
        ],
        "RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7"
      }
    }

    Example2

    Input Example

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

    Output Example

    {
      "Response": {
        "InstanceSet": [
          {
            "CPU": 64,
            "CreatedTime": "2016-12-02T00:22:40Z",
            "DataDisks": [
              {
                "DiskId": "disk-4rnslb35",
                "DiskSize": 50,
                "DiskType": "CLOUD_PREMIUM"
              }
            ],
            "ExpiredTime": "2017-01-02T00:22:48Z",
            "ImageId": "img-0vbqvzfn",
            "InstanceChargeType": "PREPAID",
            "InstanceId": "ins-r8hr2upy",
            "InstanceName": "test",
            "InstanceType": "S5.16XLARGE256",
            "InternetAccessible": {
              "InternetChargeType": "BANDWIDTH_PREPAID",
              "InternetMaxBandwidthOut": 2
            },
            "Memory": 256,
            "Placement": {
              "HostId": "",
              "ProjectId": 0,
              "Zone": "ap-shanghai-1"
            },
            "PrivateIpAddresses": [
              "10.104.37.58"
            ],
            "PublicIpAddresses": [
              "123.207.32.83"
            ],
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "SystemDisk": {
              "DiskId": "disk-4rnslbwq",
              "DiskSize": 20,
              "DiskType": "CLOUD_PREMIUM"
            },
            "VirtualPrivateCloud": {
              "AsVpcGateway": "TRUE",
              "SubnetId": "subnet-6d7kj98i",
              "VpcId": "vpc-4e78ea76"
            },
            "Tags": [
              {
                "tagKey": "city",
                "tagValue": "shenzhen"
              }
            ]
          }
        ],
        "RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7",
        "TotalCount": 1
      }
    }

    Example3

    Input Example

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

    Output Example

    {
      "Response": {
        "TotalCount": 2,
        "InstanceSet": [
          {
            "Placement": {
              "Zone": "ap-shanghai-1",
              "HostId": "",
              "ProjectId": 0
            },
            "InstanceId": "ins-r8hr2upy",
            "InstanceType": "S5.16XLARGE256",
            "CPU": 16,
            "Memory": 256,
            "InstanceName": "test",
            "InstanceChargeType": "PREPAID",
            "SystemDisk": {
              "DiskType": "CLOUD_PREMIUM",
              "DiskId": "disk-4rnslbwq",
              "DiskSize": 50
            },
            "DataDisks": [
              {
                "DiskType": "CLOUD_PREMIUM",
                "DiskId": "disk-4rnslb35",
                "DiskSize": 50
              }
            ],
            "PrivateIpAddresses": [
              "10.104.37.58"
            ],
            "PublicIpAddresses": [
              "123.207.32.83"
            ],
            "InternetAccessible": {
              "InternetMaxBandwidthOut": 2,
              "InternetChargeType": "BANDWIDTH_PREPAID"
            },
            "VirtualPrivateCloud": {
              "VpcId": "vpc-4e78ea76",
              "SubnetId": "subnet-6d7kj98i",
              "AsVpcGateway": "TRUE"
            },
            "ImageId": "img-0vbqvzfn",
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "CreatedTime": "2016-12-02T00:22:40Z",
            "ExpiredTime": "2017-01-02T00:22:48Z",
            "LatestOperation": "StopInstances",
            "LatestOperationState": "OPERATING",
            "LatestOperationRequestId": "4fe4a5a9-6be5-4154-8249-b5a5c22eaa94"
          }
        ],
        "RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7"
      }
    }

    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.

    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
    InternalServerError Internal error.
    InvalidFilter Invalid filter.
    InvalidFilterValue.LimitExceeded The number of Filter parameters exceeds the limit.
    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.LimitExceeded The number of parameter values exceeds the limit.
    InvalidZone.MismatchRegion The specified zone does not exist.