Introduction
The cPanel software provides two APIs that you can use to perform common management tasks using scripts instead of the interface. These include:
- UAPI: Access and modify cPanel account data and settings
- WHM API 1: Perform server administration tasks
Procedure
The APIs can be called with their respective commands, but you may also need to use the absolute path to the binaries to call them:
- To call the cPanel API:
uapi
/usr/local/cpanel/bin/uapi
- To call the WHM API:
whmapi1
/usr/local/cpanel/bin/whmapi1
The functions for these respective APIs are listed in our development documentation. Each available function will include an example of how to use it through the command line:
cPanel Docs: cPanel & WHM Development
Calling a uapi command requires the cPanel user, for example, to get a list of all of a user's domains:
uapi --output=jsonpretty --user=$USERNAME DomainInfo list_domains
Calling a whmapi is done as the user you are logged in as, typically root or a reseller. This will get a list of all cPanel accounts:
whmapi1 --output=jsonpretty listaccts
The "--output=jsonpretty" in both examples is optional and only makes the output more human-readable on the command line.
Comments
0 comments
Article is closed for comments.