Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function lists the cPanel account's domains.

Note:

For this function to succeed, the /var/cpanel/userdata/username/main file (where username represents the authenticated user) must possess the correct permissions. If a permissions error occurs, this function returns blank values for all of its returns and does not return an error message.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/DomainInfo/list_domains

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List the account's domains.
$get_domain_list = $cpanel->uapi(
    'DomainInfo', 'list_domains'
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List the account's domains.
my $get_domain_list = $cpliveapi->uapi(
    'DomainInfo', 'list_domains',
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- Get a hash of all the data, then display the addon_domains values. -->
[% data = execute( 'DomainInfo', 'list_domains' ); %]
[% FOREACH q = data.addon_domains %]
     <p>
         [% q %]
     </p>
[% END %]
 
<!-- Get only the addon_domains list. -->
[% execute('DomainInfo', 'list_domains').data.main_domain.domain %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=username DomainInfo list_domains

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{
    "messages": null,
    "errors": null,
    "status": 1,
    "metadata": {},
    "data": {
        "addon_domains": [
            "addondomain.com"
        ],
        "sub_domains": [
            "subdomain.example.com"
        ],
        "parked_domains": [
            "parkeddomain.com"
        ],
        "main_domain": "example.com"
    }
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

   

Parameters

This function does not accept parameters.

Returns

Note:

For this function to succeed, the /var/cpanel/userdata/username/main file (where username represents the authenticated user) must possess the correct permissions. If a permissions error occurs, this function returns blank values for all of its returns and does not return an error message.

ReturnTypeDescriptionPossible valuesExample
addon_domainsarrayAn array of addon domains.An array of string values that lists the addon domains on the cPanel account.addondomain.com
sub_domainsarrayAn array of subdomains.An array of string values that lists the subdomains on the cPanel account.subdomain.example.com
parked_domainsarrayAn array of parked domains (aliases).An array of string values that lists the parked domains on the cPanel account.parkeddomain.com
main_domainstringThe cPanel account's main domain.The cPanel account's main domain.example.com