我希望使用Google价格计算器https://cloud.google.com/products/calculator/
为云资源构建简单的结算应用谷歌是否提供与谷歌价格计算器交互的任何API?
我试过但找不到任何东西!
答案 0 :(得分:1)
根据官方文档,您可以使用Cloud Billing Catalog API:
一个例子:
请求:
GET https://cloudbilling.googleapis.com/v1/services/SERVICE_ID/skus?key=API_KEY
SERVICE_ID
是父服务的标识符。
响应:
{
"skus": [
{
"name": "[SKU_NAME]",
"skuId": "[SKU_ID]",
"description": "[SKU_DESCRIPTION]",
"category": {
"serviceDisplayName": "[SVC_DISPLAY_NAME]",
"resourceFamily": "[FAMILY]",
"resourceGroup": "[GROUP]",
"usageType": "[USAGE]",
},
"serviceRegions": [
"[REGION]"
],
"pricingInfo": [
{
"effectiveTime": "[TIME]",
"summary": "[SUMMARY]",
"pricingExpression": {
"usageUnit": "[UNIT]",
"usageUnitDescription": "[UNIT_DESCRIPTION]",
"displayQuantity": [DISPLAY_QUANTITY],
"tieredRates": [
{
"startUsageAmount": [START_AMOUNT],
"unitPrice": {
"currencyCode": "[CURRENCY_CODE]",
"units": [UNITS],
"nanos": [NANOS],
},
}
],
},
"aggregationInfo": {
"aggregationLevel": enum("[AGGREGATION_LEVEL]"),
"aggregationInterval": enum("[AGGREGATION_INTERVAL]"),
"aggregationCount": [AGGREGATION_COUNT],
},
"currencyConversionRate": [CONVERSION_RATE],
}
],
"serviceProviderName": "[SERVICE_PROVIDER]",
}
]
}
根据您的问题,您想使用以下响应对象:
[UNIT]
是指定定价的使用单位的简写。例如,GiBy
的usageUnit表示使用量是在“千兆字节”中指定的。[DISPLAY_QUANTITY]
是用于显示价格信息的建议单位数量。显示定价信息时,建议显示:(unitPrice * displayQuantity) per displayQuantity usageUnit
。该字段不影响定价公式,仅用于显示目的。例如,如果unitPrice
是“ 0.0001 USD”,usageUnit是“ GB”,而displayQuantity是“ 1000”,则推荐的定价信息显示方式是“每1000 GB 0.10 USD”。