Development Guides Home >> Guide to the LiveAPI System >> LiveAPI Methods

Guide to the LiveAPI System - The api() Method

The api() method executes a cPanel API 1 or cPanel API 2 function.

Important:

We strongly recommend that you use the appropriate method for the chosen API (api1() or api2()), rather than this method. These API-specific methods use additional internal logic to integrate with cPanel & WHM.

Example

LiveAPI PHP Class

// Execute the Email::listpopswithdisk function.
$cpanel->api(
    'exec','2','Email', 'listpopswithdisk',
    array(
        'domain'          => 'example.com',
        'nearquotaonly'   => '0',
        'no_validate'     => '0',
    )
);

LiveAPI Perl Module

# Execute the Email::listpopswithdisk function.
$cpliveapi->api(
   'exec','2','Email','listpopswithdisk',
   {
        'domain'                 => 'example.com',
        'api2_filter'            => '1',
        'api2_filter_column'     => 'diskquota',
        'api2_filter_term'       => '350',
        'api2_filter_type'       => 'lt_handle_unlimited',
    }
);

Parameters

Parameter Type Description Possible values Example
type string The request type. exec exec
version integer The cPanel API version.
  • 1 — Execute a cPanel API 1 function.
  • 2 — Execute a cPanel API 2 function.
2
module string The module name. A cPanel API 1 or cPanel API 2 module name. Email
func string The function name. A cPanel API 1 or cPanel API 2 function name. listpopswithdisk
arguments array or hash The function's input parameters and values.
  • For cPanel API 1 functions, this is an array or array reference.
  • For cPanel API 2 functions, this is a hash or hash reference.
'domain' => 'example.com'

Returns

This method returns a hash reference of the function's output.

For detailed output information, read the function's documentation.