DescribeSubnets

Last updated: 2020-08-14 10:21:12

1. API Description

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

This API (DescribeSubnets) is used to query the list of subnets.

A maximum of 100 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: vpc.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: DescribeSubnets.
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.
SubnetIds.N No Array of String Queries the ID of the subnet instance, such as subnet-pxir56ns. Each request can have a maximum of 100 instances. SubnetIds and Filters cannot be specified at the same time.
Filters.N No Array of Filter Filter condition. SubnetIds and Filters cannot be specified at the same time.
  • subnet-id - String - (Filter condition) Subnet instance name.
  • vpc-id - String - (Filter condition) VPC instance ID, such as vpc-f49l6u0z.
  • cidr-block - String - (Filter condition) The subnet IP range, such as 192.168.1.0.
  • is-default - Boolean - (Filter condition) Whether it is the default subnet.
  • is-remote-vpc-snat - Boolean - (Filter condition) Whether it is a VPC SNAT address pool subnet.
  • subnet-name - String - (Filter condition) Subnet name.
  • zone - String - (Filter condition) Availability zone.
  • tag-key - String - Required: No - (Filter condition) Filter by tag key.
  • tag:tag-key - String - Required: No - (Filter condition) Filter by tag key-value pair. The tag-key is replaced with the specific tag key. For usage, refer to case 2.
  • Offset No String Offset. Default value: 0.
    Limit No String Number of returned results. Default value: 20. Maximum value: 100.

    3. Output Parameters

    Parameter Name Type Description
    TotalCount Integer The number of instances meeting the filter condition.
    SubnetSet Array of Subnet Subnet object.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Querying the subnet list

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSubnets
    &Version=2017-03-12
    &Filters.0.Name=subnet-name
    &Filters.0.Values.0=Default Guangzhou Zone 2 subnet
    &Filters.1.Name=vpc-id
    &Filters.1.Values.0=vpc-2at5y1pn
    &Filters.2.Name=subnet-id
    &Filters.2.Values.0=subnet-otu92seu
    &Filters.3.Name=cidr-block
    &Filters.3.Values.0=172.16.16.0
    &Filters.4.Name=is-default
    &Filters.4.Values.0=true
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "SubnetSet": [
          {
            "VpcId": "vpc-2at5y1pn",
            "SubnetId": "subnet-otu92seu",
            "SubnetName": "Default Guangzhou Zone 2 subnet",
            "CidrBlock": "172.16.16.0/20",
            "Ipv6CidrBlock": "3402:4e00:20:1201::/64",
            "IsDefault": true,
            "IsRemoteVpcSnat": false,
            "EnableBroadcast": false,
            "Zone": "ap-guangzhou-dev-2",
            "RouteTableId": "rtb-l2h8d7c2",
            "TotalIpAddressCount": 4093,
            "AvailableIpAddressCount": 4002,
            "CreatedTime": "2017-04-20 11:30:48"
          }
        ],
        "TotalCount": 1,
        "RequestId": "20569756-56ba-4a13-b545-e1528d5cb239"
      }
    }

    Example2 Querying the list of subnets bound to tags

    Input Example

    https://vpc.tencentcloudapi.com/?Action=DescribeSubnets
    &Version=2017-03-12
    &Filters.0.Name=tag:city
    &Filters.0.Values.0=shanghai
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "SubnetSet": [
          {
            "VpcId": "vpc-2at5y1pn",
            "SubnetId": "subnet-otu92seu",
            "SubnetName": "Default Guangzhou Zone 2 subnet",
            "CidrBlock": "172.16.16.0/20",
            "Ipv6CidrBlock": "3402:4e00:20:1201::/64",
            "IsDefault": true,
            "IsRemoteVpcSnat": false,
            "EnableBroadcast": false,
            "Zone": "ap-guangzhou-dev-2",
            "RouteTableId": "rtb-l2h8d7c2",
            "TotalIpAddressCount": 4093,
            "AvailableIpAddressCount": 4002,
            "TagSet": [
              {
                "Key": "city",
                "Value": "shanghai"
              }
            ],
            "CreatedTime": "2017-04-20 11:30:48"
          }
        ],
        "TotalCount": 1,
        "RequestId": "20569756-56ba-4a13-b545-e1528d5cb239"
      }
    }

    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
    InvalidParameter.Coexist The parameters cannot be specified at the same time.
    InvalidParameterValue.Empty Missing parameters.
    InvalidParameterValue.LimitExceeded The parameter value exceeds the limit.
    InvalidParameterValue.Malformed Invalid input parameter format.
    InvalidParameterValue.Range The parameter value is not in the specified range.
    ResourceNotFound The resource 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