cPanel API 2 - Return Data
The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.
Introduction
cPanel API 2 outputs data in JavaScript Object Notation (JSON).
Basic return data
cPanel API 2's JSON output returns as hashes or arrays of hashes, and is never more than two layers deep.
For example, the Email::loadfilter
function's output is typical cPanel API 2 output:
{
"cpanelresult": {
"apiversion": 2,
"func": "loadfilter",
"data": [
{
"filtername": "coffee",
"actions": [
{
"dest": "/dev/null",
"number": 1,
"action": "save"
}
],
"rules": [
{
"number": 1,
"match": "is",
"part": "$header_from:",
"opt": "or",
"val": "user@example.com"
}
]
}
],
"event": {
"result": 1
},
"module": "Email"
}
}
Function call information
The following table lists arrays, hashes, and parameters that always appear in cPanel API 2 JSON output.
With the exception of the result
parameter, the function documents' lists of return parameters do not list these items.
Parameter, Array, or Hash | Description |
---|---|
cpanelresult |
The hash of return output. |
apiversion |
The cPanel API version that you called. |
func |
The function name. |
data |
The main return output array. Most functions return their output parameters within this array. |
event |
An array of information about the function call itself. All cPanel API 2 functions include the result parameter in this array. |
module |
The module name. |
View output in a Data::Dumper syntax
To view cPanel API 2 output in Data::Dumper
syntax, use the API Tracer. This utility dumps cPanel API output to the error_log
file.
Do not use the API Tracer utility on a production server. This utility presents a security risk because it can log password information.