alibaba cloud, how to get usage details including price through api

740 Views Asked by At

alibaba cloud, how to get usage details including price through api.

Through console, under billing Management > spending summary > instance spending details, able to see the all details.

2

There are 2 best solutions below

0
On

Try using BSS OpenAPI

cli:

aliyun bssopenapi QueryInstanceBill --BillingCycle 2020-09

python:

from aliyunsdkcore.client import AcsClient
from aliyunsdkbssopenapi.request.v20171214.QueryInstanceBillRequest import QueryInstanceBillRequest

client = AcsClient("accesskey", "secretkey", "eu-central-1")

request = QueryInstanceBillRequest()
request.add_query_param('BillingCycle','2020-09')
request.set_accept_format('json')

response = client.do_action_with_exception(request)

Here is the doc for this API: https://www.alibabacloud.com/help/doc-detail/100400.html?spm=a2c5t.11065259.1996646101.searchclickresult.6e427e0cOsJjA0

0
On

In your console ,you could via billing management-spending summary---details to check. but I also recommend you to use the cost management function. you would analysis your current usage and get some report suggestions, even you would send the expense budget and alarm alert. it is very useful.