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

Limit Bandwidth Usage (Transfer) — limitbw

This function modifies the bandwidth usage (transfer) limit for a specific account.

Calling Functions

Using the XML API

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

  • Append the /xml-api/limitbw 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/limitbw

  • 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 limitbw function from within your custom script:

  • Append the /json-api/limitbw 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/limitbw

  • 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 limitbw function takes the following variables as input. Both variables are required:

  • user (string) — Name of the user for whom you wish to modify the bandwidth usage limit.
  • bwlimit (string) — Bandwidth usage limit, in Megabytes.

Output

  • limitbw — Root-level XML tag for the output of the limitbw function.
    • result — Result of the bandwidth modification.
      • bwlimit (node) — The bwlimit results container.
        • bwlimit (integer) — The bandwidth limit, in bytes.
        • bwlimitenable (boolean) — Whether or not the bandwidth limit is enforced.
          • 1 — yes.
          • 0 — no.
        • domains (string) — Domains owned by the user whose bandwidth limit is being modified.
        • human_bwlimit (string) — Human-readable bandwidth usage limit, in Megabytes.
        • human_bwused (string) — Human-readable current monthly bandwidth usage, in Kilobytes.
        • unlimited (boolean) — Whether or not the account is permitted unlimited bandwidth usage.
          • 1 — yes.
          • 0 — no.
      • status (boolean) — Whether or not the edit was successful.
        • 1 — yes.
        • 0 — no.
      • statusmsg (string) — Message about the result of the operation.

Examples

XML API

Calling this function in WebHost Manager:

https://example.com:2087/xml-api/limitbw?user=username&bwlimit=5

will produce output similar to:

<limitbw>
    <result>
        <bwlimit>
             <bwlimit>5242880</bwlimit>
             <bwlimitenable>1</bwlimitenable>
             <domains>example.com</domains>
             <domains>example2.com</domains>
             <human_bwlimit>5 MB</human_bwlimit>
             <human_bwused>1.81 KB</human_bwused>
             <unlimited>0</unlimited>
        </bwlimit>
        <status>1</status>
        <statusmsg>Bandwidth Limit for username set to 5</statusmsg>
    </result>
</limitbw>

This will modify the user "username" to have a bandwidth usage limit of 5 MB.

JSON API

Calling this function in WebHost Manager:

https://example.com:2087/json-api/limitbw?user=joe&bwlimit=5

will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Bandwidth Limit for joe set to 5",
         "bwlimit":{
            "bwlimitenable":1,
            "human_bwlimit":"5 MB",
            "domains":[
               "example.com"
            ],
            "unlimited":0,
            "bwlimit":5242880,
            "human_bwused":"none"
         }
      }
   ]
}

This will modify the user "joe" to have a bandwidth usage limit of 5 MB.

Topic revision: r10 - 05 Mar 2012 - 15:01:08 - Main.JustinSchaefer