Use Billing API to get the billing related information like available balance, transactions, current usage amount, etc
HTTP Request
https://hostname:4083/index.php?act=billing
Sample Code
Curl
curl -k -X GET -L "https://hostname:4083/index.php?act=billing&api=json&apikey=your_api_key&apipass=your_api_pass"
PHP
<?php
require_once('/usr/local/virtualizor/sdk/enduser.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Enduser_API($ip, $key, $pass);
$output = $admin->billing();
print_r(json_encode($output));
?>
Output
{
"uid": "1",
"act": "billing",
"timezone": "Asia/Kolkata",
"timenow": "April 7, 2022, 1:15 pm",
"vpsid": "22",
"username": "test@test.com",
"user_type": "2",
"preferences":
{
"fname": "fname",
"lname": "lname",
"language": "english",
"theme": "default",
"timezone": "Asia/Kolkata",
},
"billing_symbol": "$",
"enable_registration": 0,
"inhouse_billing": "1",
"balance": 4997,
"charges": 0,
"cur_usage": "12.00",
"cur_invoices": "0.00",
"gateways": [],
"title": "Virtualizor",
"invoices":
{
"i_1":
{
"invoid": "1",
"invonum": "0",
"invodate": "20220331",
"invotime": "0",
"duedate": "20220331",
"uid": "1",
"paydate": "20220401",
"paytime": "1648794670",
"item": "Cloud Billing",
"additional_desc": null,
"item_desc": "",
"amt": "3.00",
"disc": "0.00",
"additional_disc": "0.00",
"net": "3.00",
"tax": null,
"token": "2",
"cancelled": "0",
"status": "paid",
"status_txt": "Paid"
}
},
"transactions":
{
"x2":
{
"trid": "2",
"uid": "1",
"date": "20220401",
"unixtime": "1648794670",
"invoid": "1",
"gateway": "",
"token": "",
"amt": "-3.00",
"fees": "0.00",
"net": "-3.00",
"bal": "4997.00",
"used": "0"
},
},
"usage":
{
"x24":
{
"usid": "24",
"vps_uuid": "tubrm0w4bxudogs2",
"uid": "1",
"serid": "0",
"sgid": "0",
"plid": "2",
"invoid": "0",
"resource": "ips",
"resource_val": "1.000",
"starttime": "1649311105",
"endtime": "0",
"updatetime": "0",
"h_used": "0.00",
"data": false,
"vpsid": "22",
"region": "Default"
},
},
"billed_usage":
{
"x4":
{
"usid": "4",
"vps_uuid": "jd2rdaeojzq4cmon",
"uid": "1",
"serid": "0",
"sgid": "0",
"plid": "2",
"invoid": "1",
"resource": "bandwidth",
"resource_val": "0.000",
"starttime": "1648680064",
"endtime": "1648799940",
"updatetime": "1648799940",
"h_used": "0.00",
"data":
{
"hostname": "host"
},
"vpsid": null,
"region": "Default"
},
},
"page":
{
"start": 0,
"len": 50,
"maxNum": "1"
},
"trpage":
{
"start": 0,
"len": 50,
"maxNum": "2"
},
"uspage":
{
"start": 0,
"len": 50,
"maxNum": "4"
},
"foreign_uid": "0",
"cb_invoice_whmcs_user": 0,
"time_taken": "0.336"
}