Introduction to the cPanel API
There are several APIs available for interacting with the cPanel software on your server.
With so many options, it's easy for users to become confused as to which API they should use for a given purpose. This document attempts to clarify this issue by explaining the cPanel APIs and their most common uses.
The cPanel APIs include:
- API version 1 (also known as API1), which is designed to generate output compatible with browsers. This API is used mainly to add, modify, or delete data on the server.
- API version 2 (also known as API2), which is also designed to generate output compatible with browsers. This API is used mainly to return data.
Although this document is devoted to the cPanel APIs, there are also 2 WHM APIs that you may find useful:
- The XML API, which is designed for integration with remote applications. You can read more about this API here.
- The JSON API, which is designed for integration with remote JavaScript applications. You can read more about it here.
Important: If you wish, you can integrate API1 and API2 functions into remote applications by using the
cpanel function call in the XML or JSON API. You can read more about this
here.
cPanel modules let you integrate the cPanel API system with your own code. You do this by creating your own API calls that can be issued from within the cPanel interface using
<cpanel> or
<?cp ?> tags.
API1
As noted above, API1 functions are designed to generate output compatible with browsers. This API is used mainly to add, modify, or delete data on the server.
Here are a few useful facts that distinguish API1 from other APIs:
- This API ordinarily prints data to the cPanel interface. As such, it's useful for creating themes or skins.
- API1 functions work well when they are called via cpanel tags. They are useful for adding, modifying, and deleting data.
- API1 functions won't return useful data when called via our XML API, or livePHP or CGI scripts.
- These functions sometimes return inline HTML, rather than XML. If you send this output to an XML parser, it will not function.
- In a few cases, API2 functions overlap with API1 functions. In those cases, using the API2 functions is preferred, since these are more up-to-date.
API2
As noted above, API2 functions, like API1 functions, are designed to generate output compatible with browsers. However, unlike API1, API2 is used mainly to return data.
Here are a few useful facts that distinguish API2 from other APIs:
- These functions normally return data structures, rather than performing any modifications on the server.
- API2 uses a templating system to print data to the cPanel interface.
- API2 functions will return useful data when called via our XML API, or livePHP or CGI scripts.
- In a few cases, API2 functions overlap with API1 functions. In those cases, using the API2 functions is preferred, since these are more up-to-date.
Topic revision: r48 - 03 Sep 2009 - 19:00:11 - Main.MelanieSeibert