Reputation: 41
I am looking to build simple billing app for cloud resources using google price calculator https://cloud.google.com/products/calculator/
Does google provide any API's for interacting with google price calculator?
I tried but couldn't find any!
Upvotes: 4
Views: 3699
Reputation: 1402
You can use the Cloud Billing Catalog API, according to the official documentation:
An example:
Request:
GET https://cloudbilling.googleapis.com/v1/services/SERVICE_ID/skus?key=API_KEY
Where SERVICE_ID
is the identifier of the parent service.
Response:
{
"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]",
}
]
}
According to your question, you would want to use these response objects:
[UNIT]
is the short hand for the unit of usage in which the pricing is specified. For example, usageUnit of GiBy
means that usage is specified in "Gibibytes".[DISPLAY_QUANTITY]
is the recommended quantity of units for displaying pricing info. When displaying pricing info, it is recommended to display: (unitPrice * displayQuantity) per displayQuantity usageUnit
. This field does not affect the pricing formula and is for display purposes only. For example, if the unitPrice
is "0.0001 USD", the usageUnit is "GB" and the displayQuantity is "1000", then the recommended way to display the pricing info is "0.10 USD per 1000 GB".Upvotes: 1