Get User Billing Statistics
To view billing statistics for a particular user, use the following request:
GET /users/:user_id/vm_stats.xml
GET /users/:user_id/vm_stats.json
If the account was created less than three months ago, the statistics are generated for the entire period of operation of the account. You can also define a shorter period by setting Start and End time in the API call:
GET /users/:user_id/vm_stats.xml?period[startdate]=YYYY-MM-DD+hh%3Amm%3Ass&period[enddate]=YYYY-MM-DD+hh%3Amm%3Ass&period[use_local_time]=1
GET /users/:user_id/vm_stats.xml?period[startdate]=YYYY-MM-DD+hh%3Amm%3Ass&period[enddate]=YYYY-MM-DD+hh%3Amm%3Ass&period[use_local_time]=1
XML Output Example
<vm_stats type="array"> <vm_hourly_stat> <created_at type="datetime">2013-05-01T00:00:28Z</created_at> <currency_code>USD</currency_code> <id type="integer">0</id> <stat_time type="datetime">2013-05-01T00:00:00Z</stat_time> <updated_at type="datetime">2013-05-01T00:00:28Z</updated_at> <user_id type="integer">239</user_id> <virtual_machine_id nil="true"/> <vm_billing_stat_id type="integer">0</vm_billing_stat_id> <total_cost type="decimal">0.0</total_cost> <usage_cost type="decimal">0.0</usage_cost> </vm_hourly_stat> <vm_hourly_stat> <created_at type="datetime">2013-05-01T01:00:27Z</created_at> <currency_code>USD</currency_code> <id type="integer">0</id> <stat_time type="datetime">2013-05-01T01:00:00Z</stat_time> <updated_at type="datetime">2013-05-01T01:00:27Z</updated_at> <user_id type="integer">239</user_id> <virtual_machine_id nil="true"/> <vm_billing_stat_id type="integer">0</vm_billing_stat_id> <total_cost type="decimal">0.0</total_cost> <usage_cost type="decimal">0.0</usage_cost> </vm_hourly_stat> <vm_stats type="array">
Where:
created_at – the timestamp in DB when this record was created
updated_at – the time stamp in DB when this record was updated
currency_code – currency in which this virtual server is charged within the bucket
id – obsolete parameter, it is always 0
stat_time – the particular hour for which these statistics were generated
user_id – the ID of VS owner
virtual_machine_id – ID of a virtual server
virtual_machine_billing_statistics_id – obsolete parameter, it is always 0
billing_stats – an array of billing details for the resources used by this VS:
The generated billing statistics will show the billing details for all virtual servers, load balancers, edge servers, and storage servers owned by this particular user. For the output examples and the explanation of the fields returned, refer to the corresponding sections:
- Get VS Billing Statistics
- Load Balancer Billing Statistics
- CDN Edge Server Billing Statistics
- Get CDN Storage Server Billing Statistics
Page History
v.5.6
- removed the vm_resources_cost parameter