Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

cPanel::runtimeexception (using api2)

Discussion in 'cPanel Developers' started by Jordan Higgins, Aug 21, 2018.

  1. Jordan Higgins

    Jordan Higgins Member

    Jul 2, 2018
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hi All,

    I have spent a few hrs attempting to dump monthly bandwidths per cPanel user as we have been requested by some clients. Below is a list of my code and the error I am getting

    The below code is the code ran from my public html folder calling from live.php (from research this file should be named .live.php and located in the folder called?)

    $test = $get_bandwidth_by_month;
    This code is directly from .live.php and is based on the information stated at Guide to the LiveAPI System - PHP Class - Developer Documentation - cPanel Documentation and
    cPanel API 2 Functions - Stats::getmonthlybandwidth - Developer Documentation - cPanel Documentation
    // Instantiate the CPANEL object.
    require_once "/usr/local/cpanel/php/cpanel.php";
    // Connect to cPanel - only do this once.
    $cpanel = new CPANEL();
    // Get domain user data.
    $get_userdata = $cpanel->uapi(
        'DomainInfo', 'domains_data',
            'format'    => 'hash',
      // Retrieve bandwidth data by month for
    $get_bandwidth_by_month = $cpanel->api2(
        'Stats', 'getmonthlydomainbandwidth'
    After following the wiki and looking online for suggestions etc I am unsure where to go from here,

    Even if I remove the //get domain user data block from .live.php it still doesn't work.

    any help you can give I will be grateful for.

    My end goal is to simply pull a list of all monthly bandwidth usage for all cPanel users and storage used compared to how much they have.. then dump it into an readable format.
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hello @Jordan Higgins,

    The LiveAPI System provides environments for applications in the cPanel interface. It's not designed to work with Apache and PHP in scripts uploaded to your website.

    If you'd like to develop PHP scripts that make use of UAPI or cPanel API 2 functions, then you'll likely want to use a PHP client class. Here's a user-submitted PHP client class for UAPI that should help you get started:


    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Jordan Higgins likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice