You can call this operation to query the price history of a preemptible instance in 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

Parameter Type Required Example Description
Action String Yes DescribeSpotPriceHistory

The operation that you want to perform. For API requests using the HTTP and HTTPS methods, the Action parameter is required. Set the value to DescribeSpotPriceHistory.

InstanceType String Yes ecs.t1.xsmall

The type of the instance.

NetworkType String Yes vpc

The network type of the preemptible instance. Valid values:

  • classic
  • vpc
RegionId String Yes cn-hangzhou

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

ZoneId String No cn-hangzhou-g

The zone ID of the instance.

SpotDuration Integer No 1

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

Default value: 1.

IoOptimized String No optimized

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

  • optimized
  • none

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

For other instance families, the default value is optimized.

StartTime String No 2017-08-22T08:45:08Z

The start time of the query. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

Default value: null. If this parameter is empty, the start time is defined as three hours earlier than the specified EndTime. You can specify a StartTime value of up to 30 days earlier than the specified EndTime.

EndTime String No 2017-08-22T08:45:08Z

The end time of the query. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

Default value: null. If this parameter is empty, the current time is used.

OSType String No linux

The type of the operating system platform. Valid values:

  • linux
  • windows
Offset Integer No 0

The start row of the query.

Default value: 0.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

NextOffset Integer 1,000

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

Currency String CNY

The currency unit of the price.

SpotPrices Array

The details of the price.

ZoneId String cn-hangzhou-c

The zone ID of the preemptible instance.

InstanceType String ecs.g5.large

The instance type of the preemptible instance.

IoOptimized String optimized

Indicates whether the preemptible instance is I/O optimized.

Timestamp String 2019-11-19T06:00:00Z

The time for the price. Format: yyyy-MM-ddTHH:MM:SS.

NetworkType String vpc

The network type of the preemptible instance.

SpotPrice Float 0.036

The spot price of the preemptible instance.

OriginPrice Float 0.354

The original price of the pay-as-you-go 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

<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

{
    "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 code Error code Error message Description
403 InvalidUserType.NotSupported %s The error message returned because the specified account does not support this operation.
403 Abs.InvalidAccount.NotFound %s The error message returned because your Alibaba Cloud account does not exist or your AccessKey pair has expired.
400 MissingParameter %s The error message returned because a required parameter is not specified.
403 Forbedden.NotSupportRAM %s The error message returned because RAM users are not allowed to perform this operation.
400 UnsupportedParameter %s The error message returned because the parameter is not supported.
403 Forbbiden.SubUser %s The error message returned because you are not authorized to operate on this resource. Apply for permissions from the Alibaba Cloud account.
400 InvalidParameter %s The error message returned because the specified parameter is invalid.
400 InvalidInstanceID.Malformed %s The error message returned because the format of the InstanceId parameter is invalid.
400 InvalidParams.StartTime %s The error message returned because the specified StartTime parameter is invalid.
400 InvalidParams.EndTime %s The error message returned because the specified EndTime parameter is invalid.
400 Abs.Abs.InvalidSpotInstanceUID %s The error message returned because the format of the preemptible instance ID is invalid.
400 InvalidParams.NetworkType %s The error message returned because the specified NetworkType parameter is invalid.
400 InvalidParams.IoOptimized %s The error message returned because the specified IoOptimized parameter is invalid.
400 InvalidParams.OSType %s The error message returned because the specified OSType parameter is invalid.
400 Abs.IoOptimized.ValueNotSupported %s The error message returned because the I/O optimization attribute of the instance is invalid. Check whether the specified IoOptimized parameter is valid.
400 InvalidZoneId.NotFound The specified zone does not exist. The error message returned because the specified zone ID does not exist.
400 InvalidParams.ZoneId %s The error message returned because the specified ZoneId parameter is invalid.
400 InvalidParams.RegionId %s The error message returned because the specified RegionId parameter is invalid.
400 InvalidParams.InstanceType %s The error message returned because the specified InstanceType parameter is invalid.
400 InvalidParams.PageSize %s The error message returned because the specified PageSize parameter is invalid.
400 InvalidParams.Offset %s The error message returned because the specified Offset parameter is invalid.
400 InvalidInstanceType.ValueNotSupported %s The error message returned because this operation cannot be performed on instances of the specified instance type.
400 DependencyViolation.IoOptimized The specified instancetype must be IoOptimized instance. The error message returned because the specified instance type is not I/O optimized.
400 InvalidSpotDuration The specified SpotDuration is not valid. The error message returned because the specified SpotDuration parameter is invalid.

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