是否有用于 Amazon Web Services 定价的 API? [英] Are there any API's for Amazon Web Services PRICING?

查看:38
本文介绍了是否有用于 Amazon Web Services 定价的 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何 API 具有 Amazon Web Services 上的最新定价?可以查询的东西,例如给定区域的最新价格 S3,或 EC2 等.

谢谢

解决方案

更新:

AWS 现在有定价 API:https://aws.amazon.com/blogs/aws/new-aws-price-list-api/

原答案:

这是我之前(通过 AWS 布道者和调查)提出的要求,但一直没有实现.我猜 AWS 的人在他们的视野中会有更多有趣的创新.

正如@brokenbeatnik 所指出的,有一个用于现货价格历史的 API.API 文档在这里:http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html

我觉得奇怪的是,现货价格历史有一个官方 API,但他们没有同时为按需服务这样做.无论如何,要回答这个问题,是的,您可以查询广告 AWS 定价...

我能想到的最好方法是检查各种服务定价页面的(客户端)来源.在其中,您会发现这些表是用 JS 构建的,并填充了 JSON 数据,这些数据您可以自己获取.例如:

这只是成功的一半,接下来您必须选择对象格式以获得您想要的值,例如,在 Python 中,这将获得弗吉尼亚的 Hi-CPU 按需超大型 Linux 实例定价:

<预><代码>>>>导入json>>>导入 urllib2>>>response = urllib2.urlopen('http://aws.amazon.com/ec2/pricing/pricing-on-demand-instances.json')>>>pricejson = response.read()>>>定价 = json.loads(pricejson)>>>定价['config']['regions'][0]['instanceTypes'][3]['sizes'][1]['valueColumns'][0]['prices']['USD']你'0.68'

免责声明:显然这不是 AWS 认可的 API,因此我不建议期望数据格式的稳定性甚至源的持续存在.但它就在那里,它胜过将定价数据转录为静态配置/源文件!

Are there any API's that have up-to-date pricing on Amazon Web Services? Something that can be queried, for example, for the latest price S3 for a given region, or EC2, etc.

thanks

解决方案

UPDATE:

AWS has pricing API nowadays: https://aws.amazon.com/blogs/aws/new-aws-price-list-api/

Original answer:

This is something I have asked for (via AWS evangelists and surveys) previously, but hasn't been forthcoming. I guess the AWS folks have more interesting innovations on their horizon.

As pointed out by @brokenbeatnik, there is an API for spot-price history. API docs here: http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSpotPriceHistory.html

I find it odd that the spot-price history has an official API, but that they didn't do this for on-demand services at the same time. Anyway, to answer the question, yes you can query the advertised AWS pricing...

The best I can come up with is from examining the (client-side) source of the various services' pricing pages. Therein you'll find that the tables are built in JS and populated with JSON data, data that you can GET yourself. E.g.:

That's only half the battle though, next you have to pick apart the object format to get at the values you want, e.g., in Python this gets the Hi-CPU On-Demand Extra-Large Linux Instance pricing for Virginia:

>>> import json
>>> import urllib2
>>> response = urllib2.urlopen('http://aws.amazon.com/ec2/pricing/pricing-on-demand-instances.json')
>>> pricejson = response.read()
>>> pricing = json.loads(pricejson)
>>> pricing['config']['regions'][0]['instanceTypes'][3]['sizes'][1]['valueColumns'][0]['prices']['USD']
u'0.68'

Disclaimer: Obviously this is not an AWS sanctioned API and as such I wouldn't recommend expecting stability of the data format or even continued existence of the source. But it's there, and it beats transcribing the pricing data into static config/source files!

这篇关于是否有用于 Amazon Web Services 定价的 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆