InquiryPriceRunInstances

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

1. API Description

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

This API is used to query the price of creating instances. You can only use this API for instances whose configuration is within the purchase limit. For more information, see RunInstances.

A maximum of 10 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: InquiryPriceRunInstances.
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.
Placement Yes Placement Location of the instance. You can use this parameter to specify the attributes of the instance, such as its availability zone and project.
ImageId Yes String Image ID in the format of img-xxx. There are four types of images:
  • Public images
  • Custom images
  • Shared images
  • Marketplace images

  • You can obtain the available image IDs in the following ways:
  • For IDs of public images, custom images, and shared images, log in to the console to query the information; for IDs of marketplace images, go to Cloud Marketplace.
  • Call DescribeImages and look for ImageId in the response.
  • InstanceChargeType No String The instance billing method.
  • POSTPAID_BY_HOUR: hourly, pay-as-you-go
    Default value: POSTPAID_BY_HOUR.
  • InstanceChargePrepaid No InstanceChargePrepaid Configuration of prepaid instances. You can use the parameter to specify the attributes of prepaid instances, such as the subscription period and the auto-renewal plan. This parameter is required for prepaid instances.
    InstanceType No String The instance model. Different resource specifications are specified for different models. For specific values, call DescribeInstanceTypeConfigs to retrieve the latest specification list or refer to Instance Types. If the parameter is not specified, S1.SMALL1 will be used by default.
    SystemDisk No SystemDisk System disk configuration of the instance. If this parameter is not specified, the default value will be used.
    DataDisks.N No Array of DataDisk The configuration information of the instance data disk. If this parameter is not specified, no data disk will be purchased by default. When purchasing, you can specify 21 data disks, which can contain at most 1 LOCAL_BASIC data disk or LOCAL_SSD data disk, and at most 20 CLOUD_BASIC data disks, CLOUD_PREMIUM data disks, or CLOUD_SSD data disks.
    VirtualPrivateCloud No VirtualPrivateCloud VPC configurations. You can use this parameter to specify the VPC ID, subnet ID, etc. If this parameter is not specified, the basic network will be used by default. If a VPC IP is specified in this parameter, the InstanceCount parameter can only be 1.
    InternetAccessible No InternetAccessible Configuration of public network bandwidth. If this parameter is not specified, 0 Mbps will be used by default.
    InstanceCount No Integer Number of instances to be purchased. Value range: [1, 100]; default value: 1. The specified number of instances to be purchased cannot exceed the remaining quota allowed for the user. For more information on quota, see CVM instance purchase limit.
    InstanceName No String Instance name to be displayed.
  • If this parameter is not specified, "Unnamed" will be displayed by default.
  • If you purchase multiple instances at the same time and specify a pattern string {R:x}, numbers [x, x+n-1] will be generated, where n represents the number of instances purchased. For example, you specify a pattern string, server_{R:3}. If you only purchase 1 instance, the instance will be named server_3; if you purchase 2, they will be named server_3 and server_4. You can specify multiple pattern strings in the format of {R:x}.
  • If you purchase multiple instances at the same time and do not specify a pattern string, the instance names will be suffixed by 1, 2...n, where n represents the number of instances purchased. For example, if you purchase 2 instances and name them as server_, the instance names will be displayed as server_1 and server_2.
  • The instance name contains up to 60 characters (including pattern strings).
  • LoginSettings No LoginSettings Login settings of the instance. You can use this parameter to set the login method, password, and key of the instance or keep the login settings of the original image. By default, a random password will be generated and sent to you via the Message Center.
    SecurityGroupIds.N No Array of String Security groups to which the instance belongs. To obtain the security group IDs, you can call DescribeSecurityGroups and look for the sgld fields in the response. If this parameter is not specified, the instance will not be associated with any security group by default.
    EnhancedService No EnhancedService Enhanced services. You can use this parameter to specify whether to enable services such as Cloud Monitor and Cloud Security. If this parameter is not specified, Cloud Monitor and Cloud Security will be enabled by default.
    ClientToken No String A string used to ensure the idempotency of the request, which is generated by the user and must be unique to each request. The maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
    For more information, see 'How to ensure idempotency'.
    HostName No String Host name of the CVM.
  • Periods (.) or hyphens (-) cannot be the start or end of a host name or appear consecutively in a host name.
  • For Windows instances, the host name must be 2-15 characters long and can contain uppercase and lowercase letters, numbers, and hyphens (-). It cannot contain periods (.) or contain only numbers.
  • For other instances, such as Linux instances, the host name must be 2-30 characters long. It supports multiple periods (.) and allows uppercase and lowercase letters, numbers, and hyphens (-) between any two periods (.).
  • TagSpecification.N No Array of TagSpecification The tag description list. This parameter is used to bind a tag to a resource instance. A tag can only be bound to CVM instances.
    InstanceMarketOptions No InstanceMarketOptionsRequest The market options of the instance.
    HpcClusterId No String HPC cluster ID.

    3. Output Parameters

    Parameter Name Type Description
    Price Price Price of the instance with the specified configurations.
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Querying the price of a pay-as-you-go instance billed on an hourly basis

    This example shows you how to query the price for purchasing one 64C256G standard (S5.16XLARGE256) instance in Shanghai Zone 2 using the image img-pmqg1cw7. The other configurations are as follows: system disk: 50 GB Premium Cloud Storage; data disk: 100 GB Premium Cloud Storage; network type: VPC; public network billing: pay-as-you-go by traffic on an hourly basis; public network bandwidth cap: 10 Mbps; public IP: randomly assigned; instance name: QCLOUD-TEST; login password: Qcloud@TestApi123++; Cloud Monitoring service: enabled; Anti-DDoS: enabled.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=InquiryPriceRunInstances
    &Placement.Zone=ap-shanghai-2
    &InstanceChargeType=POSTPAID_BY_HOUR
    &ImageId=img-pmqg1cw7
    &InstanceType=S5.16XLARGE256
    &SystemDisk.DiskType=CLOUD_PREMIUM
    &SystemDisk.DiskSize=50
    &DataDisks.0.DiskType=CLOUD_PREMIUM
    &DataDisks.0.DiskSize=100
    &InternetAccessible.InternetChargeType=TRAFFIC_POSTPAID_BY_HOUR
    &InternetAccessible.InternetMaxBandwidthOut=10
    &InternetAccessible.PublicIpAssigned=TRUE
    &InstanceName=QCLOUD-TEST
    &LoginSettings.Password=Qcloud@TestApi123++
    &EnhancedService.SecurityService.Enabled=TRUE
    &EnhancedService.MonitorService.Enabled=TRUE
    &InstanceCount=1
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "Price": {
          "InstancePrice": {
            "OriginalInstanceTypePrice": 15.95,
            "UnitPrice": 16.09,
            "UnitPriceThirdStep": 16.09,
            "Discount": 21,
            "UnitPriceDiscountThirdStep": 3.33,
            "UnitPriceSecondStep": 16.09,
            "UnitPriceDiscount": 3.33,
            "UnitPriceDiscountSecondStep": 3.33,
            "ChargeUnit": "HOUR"
          },
          "BandwidthPrice": {
            "ChargeUnit": "GB",
            "UnitPrice": 0.8,
            "Discount": 65,
            "UnitPriceDiscount": 0.52
          }
        },
        "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
      }
    }

    Example2 Querying the price of an instance with only the required parameters

    This example shows you how to create an instance using only the required Placement.Zone and ImageId parameters. The other parameters use system default values. The instance is created in Shanghai Zone 2 with image img-pmqg1cw7.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=InquiryPriceRunInstances
    &Placement.Zone=ap-shanghai-2
    &ImageId=img-pmqg1cw7
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "Price": {
          "InstancePrice": {
            "OriginalInstanceTypePrice": 0.15,
            "UnitPrice": 0.2,
            "UnitPriceThirdStep": 0.1,
            "Discount": 40,
            "UnitPriceDiscountThirdStep": 0.06,
            "UnitPriceSecondStep": 0.12,
            "UnitPriceDiscount": 0.08,
            "UnitPriceDiscountSecondStep": 0.06,
            "ChargeUnit": "HOUR"
          },
          "BandwidthPrice": {
            "ChargeUnit": "GB",
            "UnitPrice": 0,
            "Discount": 65,
            "UnitPriceDiscount": 0
          }
        },
        "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
      }
    }

    Example3 Querying the price of a monthly subscription instance

    This example shows you how to query the price for purchasing one 64C256G standard (S5.16XLARGE256) instance in Shanghai Zone 2 using the image img-pmqg1cw7. The other configurations are as follows: billing method: monthly subscription for one month with auto-renewal upon expiration; system disk: 50 GB Premium Cloud Storage; data disk: 100 GB Premium Cloud Storage; network type: VPC; public network billing: pay-as-you-go by traffic on an hourly basis; public network bandwidth cap: 10 Mbps; public IP: randomly assigned; instance name: QCLOUD-TEST; login password: Qcloud@TestApi123++; Cloud Monitoring service: enabled; Anti-DDoS: enabled.

    Input Example

    GET https://cvm.tencentcloudapi.com/?Action=InquiryPriceRunInstances
    &Placement.Zone=ap-shanghai-2
    &InstanceChargeType=PREPAID
    &InstanceChargePrepaid.Period=1
    &InstanceChargePrepaid.RenewFlag=NOTIFY_AND_AUTO_RENEW
    &ImageId=img-pmqg1cw7
    &InstanceType=S5.16XLARGE256
    &SystemDisk.DiskType=CLOUD_PREMIUM
    &SystemDisk.DiskSize=50
    &DataDisks.0.DiskType=CLOUD_PREMIUM
    &DataDisks.0.DiskSize=100
    &InternetAccessible.InternetChargeType=TRAFFIC_POSTPAID_BY_HOUR
    &InternetAccessible.InternetMaxBandwidthOut=10
    &InternetAccessible.PublicIpAssigned=TRUE
    &InstanceName=QCLOUD-TEST
    &LoginSettings.Password=Qcloud@TestApi123++
    &EnhancedService.SecurityService.Enabled=TRUE
    &EnhancedService.MonitorService.Enabled=TRUE
    &InstanceCount=1
    &<Common request parameters>

    Output Example

    {
      "Response": {
        "Price": {
          "InstancePrice": {
            "DiscountPrice": 1804.9,
            "OriginalInstanceTypePrice": 8832,
            "OriginalPrice": 8884.5,
            "Discount": 20
          },
          "BandwidthPrice": {
            "ChargeUnit": "GB",
            "UnitPrice": 0.8,
            "UnitPriceDiscount": 0.52,
            "Discount": 65
          }
        },
        "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
      }
    }

    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
    AccountQualificationRestrictions Your account failed the qualification verification.
    FailedOperation.InquiryPriceFailed Price query failed.
    InstancesQuotaLimitExceeded You are trying to create more instances than your remaining quota allows.
    InternalError.TradeUnknownError Internal error.
    InvalidClientToken.TooLong The specified ClientToken exceeds the maximum length of 64 bytes.
    InvalidHostId.Malformed Invalid CDH ID. The specified CDH ID has an invalid format. For example, host-1122 has an invalid ID length.
    InvalidHostId.NotFound The specified HostId does not exist, or does not belong to your account.
    InvalidImageId.Malformed Invalid image ID format.
    InvalidImageId.NotFound The image cannot be found.
    InvalidInstanceName.TooLong The specified InstanceName exceeds the maximum length of 60 bytes.
    InvalidInstanceType.Malformed The specified InstanceType parameter has an invalid format.
    InvalidParameter.SnapshotNotFound The specified snapshot does not exist.
    InvalidParameterCombination The parameter combination is invalid.
    InvalidParameterValue Invalid parameter value: parameter value is in the wrong format or is not supported.
    InvalidParameterValue.CloudSsdDataDiskSizeTooSmall The minimum capacity of a SSD data disk is 100 GB.
    InvalidParameterValue.InstanceTypeNotSupportHpcCluster This type of instances cannot be added to the HPC cluster.
    InvalidParameterValue.InstanceTypeRequiredHpcCluster The HPC cluster needs to be specified for the high-performance computing instance.
    InvalidParameterValue.InsufficientPrice The bid is lower than the market price.
    InvalidParameterValue.InvalidUserDataFormat Incorrect UserData format. Use the Base64-encoded format.
    InvalidParameterValue.LimitExceeded The number of parameter values exceeds the limit.
    InvalidParameterValue.Range Invalid parameter value: invalid parameter value range.
    InvalidPassword Invalid password. The specified password does not meet the password requirements. For example, the password length does not meet the requirements.
    InvalidPeriod Invalid period. Valid values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 24, 36]; unit: month.
    InvalidPermission This operation is not supported for the account.
    InvalidProjectId.NotFound Invalid project ID: the specified project ID does not exist.
    InvalidZone.MismatchRegion The specified zone does not exist.
    MissingParameter Missing parameter: a required parameter is missing.
    ResourceInsufficient.CloudDiskUnavailable The parameters of cloud disk do not meet the specification.
    ResourceNotFound.HpcCluster The HPC cluster does not exist.
    ResourceNotFound.NoDefaultCbs No default CBS resources are available.
    ResourceNotFound.NoDefaultCbsWithReason No default CBS resources are available.
    ResourceUnavailable.InstanceType This instance type is unavailable in the availability zone.
    UnsupportedOperation.BandwidthPackageIdNotSupported The specified instance or network cannot use the bandwidth package.
    UnsupportedOperation.InvalidDisk The specified disk is unsupported.
    UnsupportedOperation.OnlyForPrepaidAccount Only a prepaid account supports this operation.

    Was this page helpful?

    Was this page helpful?

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