Guide to cPanel API 1

Introduction

cPanel API 1 accesses information from the cPanel interface.

Warning:

cPanel API 1 is deprecated. We strongly recommend that you use cPanel API 2 or UAPI instead. 

 

Note:

You cannot call this API's functions via another API's call methods. For more information, read the API method distinctions section below.

Basic usage

LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
$your_variable $cpanel->api1('Module''function'array('parameter''parameter''parameter') ); // Call the function.

LiveAPI Perl Module 

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
my $your_variable $cpliveapi->api1('Module''function', ['parameter''parameter''parameter'] ); # Call the function.

Template Toolkit

Note:

Currently, individual function documentation does not include Template Toolkit examples.

1
2
3
4
5
6
7
8
9
10
11
[%- 
USE Api1;
SET myvariable = execute( 
     'Module', 'function',
    {
        'parameter'      => 'value',
        'parameter'      => 'value',
        'parameter'      => 'value',
    }
);
%]

cPanel Tag System (Deprecated) 

Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated

We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

<cpanel Module="Module::function( $FORM('parameter','parameter','parameter') )">

Command Line

cpapi1 --user=username --output=type Module function parameter=value parameter=value

Note:

cPanel & WHM introduced the command line feature in version 56.

cPanel API 1 calls through the command line consist of the following basic parts:



Part

Description

 Command

 This value is always cpapi1 for calls to cPanel API 1.

 Output Type

 The API output type that you wish to receive.

  • Use --output=json to return JSON-formatted output.
  • Use --output=jsonpretty to return indented JSON-formatted output.
  • Use --output=xml to return XML-formatted output.
  • Use --output=yaml to return YAML-formatted output.

 Note:

This parameter defaults to --output=yaml.

 Module

 The cPanel API 1 module name.

 Function

 The cPanel API 1 function.

 User

 The cPanel account-level username.

 Input parameters and values

 The function's input parameters and their values.

  • You must URI-encode values.
  • Separate multiple parameter=value pairs with a space character.
  • Special characters within a key's value may cause an error. You must either escape any special characters within values or surround the value with appropriate quotes. For more information, read Wikipedia's Escape Characters article.
    For example, a bash shell command with a JSON-encoded value may appear similar to one of the following:
    • cpapi1 --user username Module function key=[\"sslinstall\",\"videotut\"]"
    • cpapi1 --user username Module function key='{"videotut","sslinstall"}'

 

 Note:

 The term "Boolean" in our documentation refers to parameters that accept values of 1 or 0. cPanel & WHM APIs do not support the literal values of true and false.

 

 

Note:

For more information about this feature, run the following command:

cpapi1 --help

These examples use the following variables:

Variable

Description

Example

 Module

 The module for the function that you wish to use.

 Email

 function

 The cPanel API 1 function that you wish to use.

 addpop

 parameter

 Input parameters that you pass to the function.

 Important:

  • cPanel API 1 functions use ordered parameters. You must specify parameters in the order in which they appear in this documentation.
  • cPanel API 1 parameters are case-sensitive.

 

 Note:

The term "Boolean" in our documentation refers to parameters that accept values of1 or 0. cPanel & WHM APIs do not support the literal values of true and false.

 

 

 example.com 

 

 

Warning:

Do not attempt to use the URL of a cPanel or WHM interface in order to perform actions in custom code. You must call the appropriate API functions in order to perform the actions of cPanel & WHM's interfaces.

For example, do not pass values to .html pages, as in the following example:

http://example.com:2082/frontend/x3/mail/doaddpop.html/email=name&domain=user.com

While this unsupported method sometimes worked in previous versions of cPanel & WHM, we strongly discourage its use and do not guarantee that it will work in the future. Instead, the correct method to perform this action is to call the appropriate API function.

 

Call cPanel API 1 from the WHM API

Warning:

Unless you call this API via the WHM API, you cannot call this API via WHM's ports (2086 or 2087).

You can use the WHM API to call cPanel API functions. For more information, read our Use WHM API to Call cPanel API & UAPI documentation.

Important:

Because some cPanel API 1 functions return HTML output, this method will cause parsing errors in most XML parsers. We strongly recommend that you use cPanel API 2 instead.

API method distinctions

 

cPanel, Inc. produces four current and two deprecated APIs, and they all include separate sets of functions. Make certain that the function and module that you call exist in the API version that your code uses.

Important:

API calls must use the correct port:

  • 2082 — Unsecure calls to cPanel's APIs.
  • 2083 — Secure calls to cPanel's APIs.
  • 2095 — Unsecure calls to cPanel's APIs via a Webmail session.
  • 2096 — Secure calls to cPanel's APIs via a Webmail session.
  • 2086 — Unsecure calls to WHM's APIs, or to cPanel's APIs via the WHM API.
  • 2087 — Secure calls to WHM's APIs, or to cPanel's APIs via the WHM API.

Otherwise-correct calls will return Permission denied or Function not found errors if they use an incorrect port number. 

 

 




 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....