vantage-sh / ec2instances.info

Amazon EC2 instance comparison site
https://ec2instances.info
MIT License
5.07k stars 578 forks source link

Get spot prices through API calls #694

Closed ivan94fi closed 1 year ago

ivan94fi commented 1 year ago

I can query on demand prices for linux machines through the api with the following cURL call:

token="..."
instance_id="g5_2xlarge"
region="eu_west_1"
lifecycle="on_demand"

curl --request GET \
     --url "https://api.vantage.sh/v1/products/aws-ec2-$instance_id/prices/aws-ec2-$instance_id-$region-$lifecycle-linux" \
     --header 'accept: application/json' \
     --header 'authorization: Bearer $token'

However spot prices are not available, even in the listing returned by products/aws-ec2-$instance_id/prices/, while they are available in the website interface (https://instances.vantage.sh/?region=eu-west-1&selected=g5.2xlarge).

Is it possible to have spot prices through the API?

EverettBerry commented 1 year ago

Hey @ivan94fi it is possible to download these programmatically, although it is a bit clunky. You can do the following:

curl https://instances.vantage.sh/instances.json -o instances.json

Every service, including /azure has an instances file available with all the prices and specs.

ivan94fi commented 1 year ago

Thank you @EverettBerry, closing the issue. Honestly, I think it would be nice to have spot prices also in the user facing API, but for the moment being the instances.json file will do.