Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Show Bandwidth Usage — showbw

This function will display bandwidth information by account.

Calling Functions

Using the XML API

To use the XML API to perform the showbw function from within your custom script:

  • Append the /xml-api/showbw function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/showbw

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the showbw function from within your custom script:

  • Append the /json-api/showbw function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/showbw

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The showbw function takes the following optional variables as input:
  • month (integer) — The month for which you wish to view the bandwidth usage.
    • Example: 2 would request bandwidth information for the month of February.
    • note Note: This variable will only accept values of 1 through 12
  • year (integer) — The year for which you wish to view bandwidth usage.
    • Ex. 2008 would request bandwidth information from the year 2008.
    • note Note: This variable requires a 4-digit value.
  • showres (string) — The username of the reseller whose bandwidth information you wish to view.
  • search (string) — A sequence of characters for which you would like to search.
  • searchtype (string) — Specifies what kind of information you wish to search.
    • Ex. domain, user, owner, package

Output

Show Hide
  • showbw — Root-level XML tag for the output of the showbw function.
    • bandwidth — Container for the bandwidth information.
      • acct — Container for the account information.
        • deleted (boolean) — Specifies whether the account has been deleted from the server.
          • 1 — The account has been deleted.
          • 0 — The account remains on the server.
        • limit (integer) &mash; The maximum amount of bandwidth the account is allowed to use.
        • maindomain (string) — The main domain on the reseller's account.
        • owner (string) — The account owner's username.
        • reseller (boolean) — Specifies whether the account is a reseller account.
          • 1 — Account is a reseller account.
          • 0 — Account is not a reseller account.
        • user (string) — The account's username.
        • totalbytes — The amount of HTTP bandwidth used for the domain, expressed in bytes.
      • month (integer) — The month for which bandwidth information is being reported. Example: 2 would indicate bandwidth information for the month of February.
      • reseller (string) — The username of the reseller who owns the account whose bandwidth information is displayed.
      • totalused (integer) — The total amount of bandwidth used by the account.
      • year (integer) — The year for which bandwidth information is being reported.

Examples

XML API

Show Hide

Calling https://example.com:2087/xml-api/showbw?reseller=example in WebHost Manager will produce output similar to:

<showbw>
     <bandwidth>
          <acct>
                 <deleted>0</deleted>
                 <limit>0</limit>
                 <maindomain>example.com</maindomain>
                 <owner>root</owner>
                 <reseller>0</reseller>
                 <totalbytes>0</totalbytes>
                 <user>example</user>
           </acct>
           <acct>
                  <deleted>0</deleted>
                  <limit>0</limit>
                  <maindomain>domain.com</maindomain>
                  <owner>dominic</owner>
                  <reseller>1</reseller>
                  <totalbytes>0</totalbytes>
                  <user>dominic</user>
            </acct>
            <acct>
                   <deleted>0</deleted>
                   <limit>5242880</limit>
                   <maindomain>example2.com</maindomain>
                   <owner>root</owner>
                   <reseller>1</reseller>
                   <totalbytes>0</totalbytes>
                   <user>mary</user>
            </acct>
            <month>6</month>
            <reseller>root</reseller>
            <totalused>0</totalused>
            <year>2009</year>
     </bandwidth>
</showbw>

JSON API

Show Hide

Calling https://example.com:2087/json-api/showbw?reseller=example in WebHost Manager will produce something similar to:

{
   "bandwidth":[
      {
         "reseller":"root",
         "month":6,
         "acct":[
            {
               "reseller":0,
               "bwusage":[

               ],
               "deleted":0,
               "limit":"0",
               "owner":"root",
               "user":"example",
               "maindomain":"example.com",
               "totalbytes":0
            },
            {
               "reseller":"1",
               "bwusage":[

               ],
               "deleted":0,
               "limit":"0",
               "owner":"dominic",
               "user":"dominic",
               "maindomain":"domain.com",
               "totalbytes":0
            },
            {
               "reseller":"1",
               "bwusage":[

               ],
               "deleted":0,
               "limit":"5242880",
               "owner":"root",
               "user":"mary",
               "maindomain":"example2.com",
               "totalbytes":0
            }
         ],
         "totalused":"0",
         "year":2009
      }
   ]
}

Topic revision: r3 - 14 Aug 2012 - 16:41:12 - Main.StacyWyatt