You should be able to use DomainLookup::getdocroots() and DNSLookup::name2ip() for these purposes. One should note that cPanel will output duplicate data for addon domains.

For example, domain1.com is your main domain on the account. You add domain2.com as an addon domain. When outputting all the domains, you get an entry for domain2.com as well as the subdomain alias domain2.domain1.com. I've found it necessary to remove this subdomain alias from anything that is shown to customers as it can cause a lot of confusion.

You can use the cPanel LiveAPI Perl module interface if you're going to have cPanel users directly interacting with the script via URL: