All Products
Search
Document Center

Elastic Compute Service:DescribeSpotPriceHistory

Last Updated:Jun 29, 2026

Queries the historical prices of spot instances. You can query price data from the last 30 days. The historical price data helps you set a reasonable maximum price for a spot instance.

Operation description

  • Only I/O optimized spot instances are supported.

  • The data returned by this operation may be paginated. If the response contains the NextOffset parameter, set the Offset request parameter to the value of NextOffset to query the next page of data.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

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

cn-hangzhou

RegionId

string

Yes

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

cn-hangzhou

ZoneId

string

No

The zone ID.

cn-hangzhou-g

NetworkType

string

Yes

The network type of the spot instance. Valid values:

  • vpc: virtual private cloud (VPC).

  • classic: classic network. This feature has been retired. For more information, see Retirement notice.

vpc

InstanceType

string

Yes

The instance type.

ecs.t1.xsmall

SpotDuration

integer

No

The protection period of the spot instance. Unit: hours. Default value: 1. Valid values:

  • 1: After a spot instance is created, Alibaba Cloud ensures that the instance is not automatically released within 1 hour. After 1 hour, the system compares the bid price with the market price and checks the resource inventory to determine whether to retain automatic release the instance.

  • 0: After a spot instance is created, Alibaba Cloud does not ensure that the instance runs for 1 hour. The system compares the bid price with the market price and checks the resource inventory to determine whether to retain automatic release the instance.

Alibaba Cloud sends an ECS system event notification 5 minutes before the instance is released. Spot instances are billed by second. Specify an appropriate protection period based on the expected task execution duration.

Note

This parameter takes effect only when SpotStrategy is set to SpotWithPriceLimit or SpotAsPriceGo.

1

IoOptimized

string

No

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

  • optimized: The spot instance is an I/O optimization instance.

  • none: The spot instance is not an I/O optimization instance.

Default value for Generation I instance families: none.

Default value for other instance families: optimized.

optimized

StartTime

string

No

The beginning of the time range to query the historical prices of spot instances. The maximum time range between the start time and end time is 30 days. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Default value: null, which indicates 3 hours before the end time.

2017-08-22T08:45:08Z

EndTime

string

No

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

Default value: null, which indicates the current time.

2017-08-22T08:45:08Z

OSType

string

No

The type of the operating system platform. Valid values:

  • linux.

  • windows.

linux

Offset

integer

No

The row from which the query starts.

Default value: 0.

0

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Currency

string

The currency unit of the price.

China site: CNY.

International site: USD.

CNY

NextOffset

integer

The start row of the next page. Set the Offset parameter to this value to query the next page of data.

1000

SpotPrices

object

SpotPriceType

array<object>

The details of the spot prices.

object

IoOptimized

string

Details about the price history of the spot instance.

optimized

ZoneId

string

The ID of the request.

cn-hangzhou-c

SpotPrice

number

The price for a pay-as-you-go instance that has the same configurations as the spot instance.

0.036

Timestamp

string

The currency unit of the price.

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

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

2019-11-19T06:00:00Z

NetworkType

string

Queries the price history of a spot instance within the last 30 days.

vpc

InstanceType

string

The instance type of the spot instance.

ecs.g5.large

OriginPrice

number

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

0.354

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "Currency": "CNY",
  "NextOffset": 1000,
  "SpotPrices": {
    "SpotPriceType": [
      {
        "IoOptimized": "optimized",
        "ZoneId": "cn-hangzhou-c",
        "SpotPrice": 0.036,
        "Timestamp": "2019-11-19T06:00:00Z",
        "NetworkType": "vpc",
        "InstanceType": "ecs.g5.large",
        "OriginPrice": 0.354
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 MissingParameter %s A parameter is not specified.
400 UnsupportedParameter %s The parameter is not supported.
400 InvalidParameter %s The specified parameter is invalid.
400 InvalidInstanceID.Malformed %s The specified InstanceId parameter is invalid.
400 InvalidParams.StartTime %s The specified StartTime parameter is invalid.
400 InvalidParams.EndTime %s The specified EndTime parameter is invalid.
400 Abs.Abs.InvalidSpotInstanceUID %s The preemptible instance ID is invalid.
400 InvalidParams.NetworkType %s The specified NetworkType parameter is invalid.
400 InvalidParams.IoOptimized %s The specified IoOptimized parameter is invalid.
400 InvalidParams.OSType %s The specified OSType parameter is invalid.
400 Abs.IoOptimized.ValueNotSupported %s 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 specified zone ID does not exist.
400 InvalidParams.ZoneId %s The specified ZoneId parameter is invalid.
400 InvalidParams.RegionId %s The specified RegionId parameter is invalid.
400 InvalidParams.InstanceType %s The specified InstanceType parameter is invalid.
400 InvalidParams.PageSize %s The specified PageSize parameter is invalid.
400 InvalidParams.Offset %s The specified Offset parameter is invalid.
400 InvalidInstanceType.ValueNotSupported %s The operation is not supported by the specified instance type.
400 DependencyViolation.IoOptimized The specified instancetype must be IoOptimized instance. The specified instance type must be I/O optimized. Check your instance type and try again.
400 InvalidSpotDuration The specified SpotDuration is not valid. The specified SpotDuration parameter is invalid.
400 OperationDenied.QueryFail Query spot price fail, please retry later.
403 InvalidUserType.NotSupported %s Your account does not support this operation.
403 Abs.InvalidAccount.NotFound %s Your Alibaba Cloud account does not exist or your AccessKey pair has expired.
403 Forbedden.NotSupportRAM %s RAM users are not authorized to perform this operation.
403 Forbbiden.SubUser %s You are not authorized to manage this resource. Contact the owner of the Alibaba Cloud account for authorization.
403 OperationDenied.RegionIdNotSupported region not support spot duration instance.
403 OperationDenied.FlavorNotSupported flavor not support spot duration instance.
403 OperationDenied.TimestampNotSupported timestamp not support spot duration instance.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.