Using CPanel/WHM API to get detail list of all accounts on server
Today I had this need to get a list of WHM Accounts using one of its APIs. I have never used it before but it was really simple to use. It returns an xml file that you can manipulate using your prefered language and store it in database for reporting etc.
Here is what you need to do, connect to your server using SSH and run the following command
wget http://your-server-ip:2086/xml-api/listaccts --http-user=myuser --http-password=mypass --output-document=listaccts.xml
Replace your-server-ip with your WHM’s ip and myuser/mypass with the actual WHM/CPanel password. The resultant xml file will be saved as “listaccts.xml” in the same directory as you ran the command in.
If you feel a bit insecure running these command over SSH or don’t have shell access to the server then visit this page on your browser and save it as an xml file.
http://your-server-ip:2086/xml-api/listaccts
(again, substitute your-server-ip with the actual WHM ip address, substitute HTTP with HTTPS and port to 2087 for HTTPS if enabled on your server / FQDN)
Enjoy!