Description

This function displays a domain's bandwidth usage data by month.

Examples


https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Stats&cpanel_jsonapi_func=getmonthlydomainbandwidth

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Retrieve bandwidth data by month for example.com
$get_bandwidth_by_month = $cpanel->api2(
    'Stats', 'getmonthlydomainbandwidth'
    ) 
 );

 

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Retrieve bandwidth data by month for example.com
my $get_bandwidth_by_month = $cpliveapi->api2(
    'Stats', 'getmonthlydomainbandwidth',
 );

cpapi2 --user=username Stats getmonthlydomainbandwidth

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "getmonthlydomainbandwidth",
    "data": [
      {
        "bw": {
          "example.com": 672
        },
        "date": "2014-10"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Stats"
  }
}

Parameters

This function does not accept parameters.

 

Returns

ReturnTypeDescriptionPossible valuesExample
bwhashThe domain and the current month's bandwidth usage, in bytes.The domain, a colon (:), and a positive integer.example.com: 672

date

stringThe current month, in YYYY-MM format.

A date in YYYY-MM format, where:

  • YYYY represents the four-digit year.
  • MM represents the two-digit month.
2014-04
reasonstring

A reason for failure.

This function only returns a reason value if there was an error.

A string that describes the error. This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1