Queries the price history of a preemptible instance over the last 30 days.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesDescribeSpotPriceHistory

The operation that you want to perform. Set the value to DescribeSpotPriceHistory.

RegionIdStringYescn-hangzhou

The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list.

ZoneIdStringNocn-hangzhou-g

The zone ID of the instance.

NetworkTypeStringYesvpc

The network type of the preemptible instance. Valid values:

  • classic
  • vpc
InstanceTypeStringYesecs.t1.xsmall

The instance type of the instance.

SpotDurationIntegerNo1

The protection period of the preemptible instance. Unit: hours. Valid values: 0, 1, 2, 3, 4, 5, and 6.

  • Protection periods of 2, 3, 4, 5, and 6 hours are in invitational preview. If you want to set this parameter to one of these values, submit a ticket.
  • If this parameter is set to 0, no protection period is configured for the preemptible instance.

Default value: 1.

IoOptimizedStringNooptimized

Specifies whether the instance is I/O optimized. Valid values:

  • optimized: The instance is I/O optimized.
  • none: The instance is not I/O optimized.

For generation I instance families, the default value is none.

For other instance families, the default value is optimized.

StartTimeStringNo2017-08-22T08:45:08Z

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

This parameter is empty by default. If this parameter is empty, it indicates 3 hours earlier than the specified EndTime value. You can specify a StartTime value of up to 30 days earlier than the specified EndTime value.

EndTimeStringNo2017-08-22T08:45:08Z

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

This parameter is empty by default. If this parameter is empty, the current time is used.

OSTypeStringNolinux

The type of the operating system platform. Valid values:

  • linux
  • windows
OffsetIntegerNo0

The line from which the next query starts.

Default value: 0.

Response parameters

ParameterTypeExampleDescription
RequestIdString473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

CurrencyStringCNY

The currency unit of the price.

Alibaba Cloud China site (aliyun.com): CNY.

Alibaba Cloud International site (alibabacloud.com): USD.

NextOffsetInteger1000

The start row of the next page. It is the value of the Offset parameter.

SpotPricesArray of SpotPriceType

Details about the spot prices.

SpotPriceType
IoOptimizedStringoptimized

Indicates whether the preemptible instance is I/O optimized.

ZoneIdStringcn-hangzhou-c

The zone ID of the preemptible instance.

SpotPriceFloat0.036

The spot price of the preemptible instance.

TimestampString2019-11-19T06:00:00Z

The time that corresponds to the queried spot price. The time is in the yyyy-MM-ddTHH:mm:ssZ format.

NetworkTypeStringvpc

The network type of the preemptible instance.

InstanceTypeStringecs.g5.large

The instance type of the preemptible instance.

OriginPriceFloat0.354

The price for a pay-as-you-go instance that has the same configuration as the specified preemptible instance.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DescribeSpotPriceHistory
&NetworkType=vpc
&RegionId=cn-hangzhou
&InstanceType=ecs.g5.large
&StartTime=2019-11-19T00:00:00Z
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeSpotPriceHistoryResponse>
    <RequestId>5E2D59BA-4EB0-45C4-A0D7-D98C1A4B320B</RequestId>
    <SpotPrices>
        <SpotPriceType>
            <IoOptimized>optimized</IoOptimized>
            <OriginPrice>0.354</OriginPrice>
            <NetworkType>vpc</NetworkType>
            <ZoneId>cn-hangzhou-g</ZoneId>
            <Timestamp>2019-11-19T06:00:00Z</Timestamp>
            <SpotPrice>0.036</SpotPrice>
            <InstanceType>ecs.g5.large</InstanceType>
        </SpotPriceType>
        <SpotPriceType>
            <IoOptimized>optimized</IoOptimized>
            <OriginPrice>0.354</OriginPrice>
            <NetworkType>vpc</NetworkType>
            <ZoneId>cn-hangzhou-g</ZoneId>
            <Timestamp>2019-11-19T07:00:00Z</Timestamp>
            <SpotPrice>0.036</SpotPrice>
            <InstanceType>ecs.g5.large</InstanceType>
        </SpotPriceType>
    </SpotPrices>
    <Currency>CNY</Currency>
</DescribeSpotPriceHistoryResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "5E2D59BA-4EB0-45C4-A0D7-D98C1A4B320B",
  "SpotPrices" : {
    "SpotPriceType" : [ {
      "IoOptimized" : "optimized",
      "OriginPrice" : 0.354,
      "NetworkType" : "vpc",
      "ZoneId" : "cn-hangzhou-g",
      "Timestamp" : "2019-11-19T06:00:00Z",
      "SpotPrice" : 0.036,
      "InstanceType" : "ecs.g5.large"
    }, {
      "IoOptimized" : "optimized",
      "OriginPrice" : 0.354,
      "NetworkType" : "vpc",
      "ZoneId" : "cn-hangzhou-g",
      "Timestamp" : "2019-11-19T07:00:00Z",
      "SpotPrice" : 0.036,
      "InstanceType" : "ecs.g5.large"
    } ]
  },
  "Currency" : "CNY"
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter%sThe error message returned because a required parameter is not specified.
400UnsupportedParameter%sThe error message returned because a specified parameter is not supported.
400InvalidParameter%sThe error message returned because a specified parameter is invalid.
400InvalidInstanceID.Malformed%sThe error message returned because the specified InstanceId parameter is invalid.
400InvalidParams.StartTime%sThe error message returned because the specified StartTime parameter is invalid.
400InvalidParams.EndTime%sThe error message returned because the specified EndTime parameter is invalid.
400Abs.Abs.InvalidSpotInstanceUID%sThe error message returned because the format of the preemptible instance ID is invalid.
400InvalidParams.NetworkType%sThe error message returned because the specified NetworkType parameter is invalid.
400InvalidParams.IoOptimized%sThe error message returned because the specified IoOptimized parameter is invalid.
400InvalidParams.OSType%sThe error message returned because the specified OSType parameter is invalid.
400Abs.IoOptimized.ValueNotSupported%sThe error message returned because the specified IoOptimized parameter is invalid.
400InvalidZoneId.NotFoundThe specified zone does not exist.The error message returned because the specified ZoneId parameter does not exist.
400InvalidParams.ZoneId%sThe error message returned because the specified ZoneId parameter is invalid.
400InvalidParams.RegionId%sThe error message returned because the specified RegionId parameter is invalid.
400InvalidParams.InstanceType%sThe error message returned because the specified InstanceType parameter is invalid.
400InvalidParams.PageSize%sThe error message returned because the specified PageSize parameter is invalid.
400InvalidParams.Offset%sThe error message returned because the specified Offset parameter is invalid.
400InvalidInstanceType.ValueNotSupported%sThe error message returned because the operation is not supported by the specified instance type.
400DependencyViolation.IoOptimizedThe specified instancetype must be IoOptimized instance.The error message returned because the specified instance type is not I/O optimized.
400InvalidSpotDurationThe specified SpotDuration is not valid.The error message returned because the specified SpotDuration parameter is invalid.
403InvalidUserType.NotSupported%sThe error message returned because your account does not support this operation.
403Abs.InvalidAccount.NotFound%sThe error message returned because your Alibaba Cloud account does not exist or because your AccessKey pair has expired.
403Forbedden.NotSupportRAM%sThe error message returned because RAM users are not authorized to perform this operation.
403Forbidden.SubUser%sThe error message returned because you are not authorized to manage this resource. Contact the owner of the Alibaba Cloud account for authorization.

For a list of error codes, visit the API Error Center.