cPanel API 2 - Output Columns

Warning:

The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.


Introduction

You can use special variables to select the parameters to display in cPanel API 2 output.

Note:

You can test cPanel API 2 functions with column selection in cPanel's API Shell interface (Home >> Advanced >> API Shell). Click Show paginate/Filter/Paginate Options to display column selection options.


Column selection variables

cPanel API 2 column selection uses two basic variables:

Variable Type Description Possible values
api2_columns Boolean Whether to enable columns.
  • 1 — Enable columns.
  • 0 — Disable columns.
api2_columns_a string The parameter that you wish to display. A valid parameter name for the function.

To output multiple columns on a single cPanel API 2 call, add another string variable that uses the next letter in the alphabet (For example, api2_columns_b, api2_columns_c, api2_columns_d.)

Examples

The following example displays the ip and timestamp parameter results for the Stats::lastvisitors function.

WHM API

/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_xmlapi_apiversion=2&cpanel_xmlapi_user=user&cpanel_xmlapi_module=Stats&cpanel_xmlapi_func=lastvisitors&domain=example.com&api2_sort=1&api2_columns_a=ip&api2_columns_b=timestamp&api2_columns=1
Note:

For more information, read our Use WHM API to Call cPanel API and UAPI documentation.


LiveAPI PHP Class

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// Call the listvisitors function and display only ip and timestamp.
$limited_visitors = $cpanel->api2(
    'Stats', 'lastvisitors',
    array(
        'domain'                     => 'example.com',
        'api2_columns'               => '1',
        'api2_columns_a'             => 'ip',
        'api2_columns_b'             => 'timestamp',
    )
);
Note:

For more information, read our Guide to LiveAPI System documentation.


LiveAPI Perl Class

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# Call the listvisitors function and display only ip and timestamp.
my $limited_visitors = $cpliveapi->api2(
    'Stats', 'lastvisitors',
    {
        'domain'                     => 'example.com',
        'api2_columns'               => '1',
        'api2_columns_a'             => 'ip',
        'api2_columns_b'             => 'timestamp',
    }
);
Note:

For more information, read our Guide to LiveAPI System documentation.


Command Line

cpapi2 --user=username Stats lastvisitors api2_columns=1 api2_columns_a=ip api2_columns_b=timestamp

cPanel Tag System (deprecated)

<?cp Email::listpopswithdisk (
          %[br],
          ip
          )
          domain="example.com",
          api2_columns="1",
          api2_columns_a="ip",
          api2_columns_b="timestamp",
?>
Warning:
  • cPanel tags are deprecated . We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI .
  • cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
  • For more information, read our Deprecated cPanel Tag Usage documentation.