tencent cloud

文档反馈

InquiryPriceRunInstances

最后更新时间:2024-01-04 16:11:09

    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.

    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 Params. The value used for this API: InquiryPriceRunInstances.
    Version Yes String Common Params. The value used for this API: 2017-03-12.
    Region No String Common Params. This parameter is not required for this API.
    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.
    Note: Placement is required when LaunchTemplate is not specified. If both the parameters are passed in, Placement prevails.
    ImageId Yes String Image ID in the format of img-xxx. There are three types of images:
  • Public images
  • Custom images
  • Shared 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 CVM console to query the information.
  • Call DescribeImages and look for ImageId in the response.

  • Note: ImageId is required when LaunchTemplate is not specified. If both the parameters are passed in, ImageId prevails.
    InstanceChargeType No String The instance billing method.
  • POSTPAID_BY_HOUR: Pay-as-you-go on an hourly basis
    Default value: POSTPAID_BY_HOUR.
  • InstanceChargePrepaid No InstanceChargePrepaid Details of the monthly subscription, including the purchase period, auto-renewal. It is required if the InstanceChargeType is PREPAID.
    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 Data disk configuration of the instance. If the parameter is not specified, no data disk will be purchased by default. If you want to purchase data disks, you can specify 21 data disks, including up to 1 LOCAL_BASIC data disk or LOCAL_SSD data disk and up to 20 CLOUD_BASIC data disks, CLOUD_PREMIUM data disks, or CLOUD_SSD data disks.
    VirtualPrivateCloud No VirtualPrivateCloud VPC configurations (VPC ID, subnet ID, etc). If it’s not specified, the classic network will be used by default. If a VPC IP is specified in this parameter, the InstanceCount can only be 1.
    InternetAccessible No InternetAccessible Configuration of public network bandwidth. If it’s not specified, 0 Mbps is used by default.
    InstanceCount No Integer Number of instances to purchase. Value range: 1 (default) to 100. It cannot exceed the remaining CVM quota of the user. For more information on quota, see Restrictions on CVM Instance Purchase.
    InstanceName No String Instance name (up to 60 characters)
  • 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 the instance name body is server_, the instance names will be server_1 and server_2.
  • 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 original login settings of the 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 Security and Cloud Monitor. If this parameter is not specified, Cloud Monitor and Cloud Security will be enabled by default.
    ClientToken No String A unique string supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idempotency of the request cannot be guaranteed.
    For more information, see Ensuring 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.
  • Windows: 2-15 characters, containing [a-z], [A-Z], [0-9] and hyphens (-). Digit-only strings are not allowed.
  • 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 an instance with only the required parameters

    This example queries the price of creating an instance in Shanghai Zone 2 with the image img-pmqg1cw7. Only the required Placement.Zone and ImageId parameters are passed in. The other parameters use system default values.

    Input Example

    POST / HTTP/1.1
    Host: cvm.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: InquiryPriceRunInstances
    <Common request parameters>
    
    {
        "Placement": {
            "Zone": "ap-shanghai-2"
        },
        "ImageId": "img-pmqg1cw7"
    }
    

    Output Example

    {
        "Response": {
            "Price": {
                "InstancePrice": {
                    "DiscountPrice": 0.0,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 0.2,
                    "UnitPriceThirdStep": 0.1,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 0.06,
                    "UnitPriceSecondStep": 0.12,
                    "OriginalPrice": 0.0,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 0.06,
                    "UnitPriceDiscount": 0.08,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "HOUR",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                },
                "BandwidthPrice": {
                    "DiscountPrice": 0.0,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 0.0,
                    "UnitPriceThirdStep": 0.0,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 0.0,
                    "UnitPriceSecondStep": 0.0,
                    "OriginalPrice": 0.0,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 0.0,
                    "UnitPriceDiscount": 0.0,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "HOUR",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                }
            },
            "RequestId": "65b9edac-bca6-496b-a404-29f503b32495"
        }
    }
    

    Example2 Querying the price of a monthly-subscribed 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 Monitor service: enabled; Anti-DDoS: enabled.

    Input Example

    POST / HTTP/1.1
    Host: cvm.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: InquiryPriceRunInstances
    <Common request parameters>
    
    {
        "SystemDisk": {
            "DiskSize": "50",
            "DiskType": "CLOUD_PREMIUM"
        },
        "InstanceCount": "1",
        "Placement": {
            "Zone": "ap-shanghai-2"
        },
        "LoginSettings": {
            "Password": "Qcloud@TestApi123++"
        },
        "ImageId": "img-pmqg1cw7",
        "InstanceChargeType": "PREPAID",
        "EnhancedService": {
            "SecurityService": {
                "Enabled": "TRUE"
            },
            "MonitorService": {
                "Enabled": "TRUE"
            }
        },
        "InternetAccessible": {
            "PublicIpAssigned": "TRUE",
            "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR",
            "InternetMaxBandwidthOut": "10"
        },
        "InstanceChargePrepaid": {
            "RenewFlag": "NOTIFY_AND_AUTO_RENEW",
            "Period": "1"
        },
        "InstanceName": "QCLOUD-TEST",
        "InstanceType": "S5.16XLARGE256",
        "DataDisks": [
            {
                "DiskSize": "100",
                "DiskType": "CLOUD_PREMIUM"
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "Price": {
                "InstancePrice": {
                    "DiscountPrice": 1804.9,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 0.0,
                    "UnitPriceThirdStep": 0.0,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 0.0,
                    "UnitPriceSecondStep": 0.0,
                    "OriginalPrice": 8884.5,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 0.0,
                    "UnitPriceDiscount": 0.0,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "HOUR",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                },
                "BandwidthPrice": {
                    "DiscountPrice": 0.0,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 0.8,
                    "UnitPriceThirdStep": 0.0,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 0.0,
                    "UnitPriceSecondStep": 0.0,
                    "OriginalPrice": 0.0,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 0.0,
                    "UnitPriceDiscount": 0.52,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "HOUR",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                }
            },
            "RequestId": "65b9edac-bca6-496b-a404-29f503b32495"
        }
    }
    

    Example3 Querying the price of an hourly-billed pay-as-you-go 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 mode: pay-as-you-go on an hourly basis; 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 Monitor service: enabled; Anti-DDoS: enabled.

    Input Example

    POST / HTTP/1.1
    Host: cvm.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: InquiryPriceRunInstances
    <Common request parameters>
    
    {
        "SystemDisk": {
            "DiskSize": "50",
            "DiskType": "CLOUD_PREMIUM"
        },
        "InstanceCount": "1",
        "Placement": {
            "Zone": "ap-shanghai-2"
        },
        "LoginSettings": {
            "Password": "Qcloud@TestApi123++"
        },
        "ImageId": "img-pmqg1cw7",
        "InstanceChargeType": "POSTPAID_BY_HOUR",
        "EnhancedService": {
            "SecurityService": {
                "Enabled": "TRUE"
            },
            "MonitorService": {
                "Enabled": "TRUE"
            }
        },
        "InternetAccessible": {
            "PublicIpAssigned": "TRUE",
            "InternetChargeType": "TRAFFIC_POSTPAID_BY_HOUR",
            "InternetMaxBandwidthOut": "10"
        },
        "InstanceName": "QCLOUD-TEST",
        "InstanceType": "S5.16XLARGE256",
        "DataDisks": [
            {
                "DiskSize": "100",
                "DiskType": "CLOUD_PREMIUM"
            }
        ]
    }
    

    Output Example

    {
        "Response": {
            "Price": {
                "InstancePrice": {
                    "DiscountPrice": 0.0,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 16.09,
                    "UnitPriceThirdStep": 16.09,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 3.33,
                    "UnitPriceSecondStep": 16.09,
                    "OriginalPrice": 0.0,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 3.33,
                    "UnitPriceDiscount": 3.33,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "HOUR",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                },
                "BandwidthPrice": {
                    "DiscountPrice": 0.0,
                    "OriginalPriceThreeYear": 0.0,
                    "DiscountOneYear": 0.0,
                    "UnitPrice": 0.8,
                    "UnitPriceThirdStep": 0.0,
                    "OriginalPriceFiveYear": 0.0,
                    "Discount": 0.0,
                    "DiscountFiveYear": 0.0,
                    "UnitPriceDiscountThirdStep": 0.0,
                    "UnitPriceSecondStep": 0.0,
                    "OriginalPrice": 0.0,
                    "DiscountThreeYear": 0.0,
                    "UnitPriceDiscountSecondStep": 0.0,
                    "UnitPriceDiscount": 0.52,
                    "DiscountPriceFiveYear": 0.0,
                    "OriginalPriceOneYear": 0.0,
                    "ChargeUnit": "xx",
                    "DiscountPriceThreeYear": 0.0,
                    "DiscountPriceOneYear": 0.0
                }
            },
            "RequestId": "65b9edac-bca6-496b-a404-29f503b32495"
        }
    }
    

    5. Developer Resources

    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.
    AuthFailure.CamRoleNameAuthenticateFailed Role name authentication failed.
    FailedOperation.DisasterRecoverGroupNotFound The specified spread placement group does not exist.
    FailedOperation.IllegalTagKey The tag key contains invalid characters.
    FailedOperation.IllegalTagValue The tag value contains invalid characters.
    FailedOperation.InquiryPriceFailed Price query failed.
    FailedOperation.SnapshotSizeLargerThanDataSize The snapshot size is larger than the disk capacity. You need a larger disk space.
    FailedOperation.TagKeyReserved The tag key specified in the request is reserved for the system.
    FailedOperation.TatAgentNotSupport This image is not a Linux&x86_64 image.
    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.InstanceImageNotSupport This API does not support instance images.
    InvalidParameter.InternetAccessibleNotSupported Unable to set the public network bandwidth.
    InvalidParameter.SnapshotNotFound The specified snapshot does not exist.
    InvalidParameterCombination The parameter combination is invalid.
    InvalidParameterValue Incorrect parameter value.
    InvalidParameterValue.BandwidthPackageIdMalformed The shared bandwidth package ID is invalid. Please provide a standard shared bandwidth package ID in the format similar to bwp-xxxxxxxx. In this format, the letter x stands for a lowercase character or a number.
    InvalidParameterValue.BandwidthPackageIdNotFound The specified bandwidth package does not exist.
    InvalidParameterValue.CloudSsdDataDiskSizeTooSmall The minimum capacity of a SSD data disk is 100 GB.
    InvalidParameterValue.DuplicateTags Duplicate tags.
    InvalidParameterValue.InstanceTypeNotFound The specified instance type does not exist.
    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.InvalidAppIdFormat Invalid AppID
    InvalidParameterValue.InvalidImageFormat A RAW image cannot be used to create a CVM. Choose another image.
    InvalidParameterValue.InvalidImageId The image does not support this operation.
    InvalidParameterValue.InvalidImageOsName The operating system of the specified image is not available in the current region.
    InvalidParameterValue.InvalidImageState The image has another ongoing task. Please check and try again later.
    InvalidParameterValue.InvalidTimeFormat Incorrect time format.
    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.
    InvalidParameterValue.RequiredLocationImage
    InvalidParameterValue.SnapshotIdMalformed Invalid snapshot ID. Provide a snapshot ID in the format of snap-xxxxxxxx, where the letter x refers to lowercase letter or number.
    InvalidParameterValue.TagKeyNotFound The specified tag does not exist
    InvalidParameterValue.TagQuotaLimitExceeded Tag quota limit exceeded.
    InvalidParameterValue.ZoneNotSupported The availability zone does not support this operation.
    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.
    LimitExceeded.DisasterRecoverGroup The quota of the specified placement group is insufficient.
    LimitExceeded.InstanceEniNumLimit Reached the upper limit of the ENIs for the instance.
    MissingParameter Missing parameter.
    MissingParameter.MonitorService The instance type must have Cloud Monitor enabled.
    ResourceInsufficient.CloudDiskUnavailable The parameters of cloud disk do not meet the specification.
    ResourceInsufficient.DisasterRecoverGroupCvmQuota The number of instances exceeded the quota limit of spread placement groups.
    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.
    ResourcesSoldOut.SpecifiedInstanceType The specified instance type is sold out.
    UnsupportedOperation.BandwidthPackageIdNotSupported The specified instance or network cannot use the bandwidth package.
    UnsupportedOperation.InvalidDisk The specified disk is not supported.
    UnsupportedOperation.InvalidRegionDiskEncrypt Encrypted disks are not available in the selected regions.
    UnsupportedOperation.NoInstanceTypeSupportSpot This instance type does not support spot instances.
    UnsupportedOperation.NotSupportImportInstancesActionTimer Failed to configure the scheduled action for the current instance.
    UnsupportedOperation.OnlyForPrepaidAccount Only a prepaid account supports this operation.
    UnsupportedOperation.SpotUnsupportedRegion Spot instance is not supported in this region.
    UnsupportedOperation.UnderwritingInstanceTypeOnlySupportAutoRenew For an underwriting instance, RenewFlag can only be set to NOTIFY_AND_AUTO_RENEW.
    UnsupportedOperation.UnsupportedInternationalUser This operation is not available for Tencent Cloud International users.