UAPI Functions - DomainInfo::domains_data

Description

This function lists user data for the cPanel account's domains.

Note:

This function retrieves data from the /var/cpanel/userdata/user/domain file, where user represents the cPanel account username and domain represents the domain. For this reason, actual output may not contain all of the return parameters.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/DomainInfo/domains_data?format=hash

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Get domain user data.
$get_userdata $cpanel->uapi(
    'DomainInfo''domains_data',
    array(
        'format'    => 'hash',
    )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Get domain user data.
my $get_userdata $cpliveapi->uapi(
    'DomainInfo''domains_data',
    {
        'format'    => 'hash',
    }
);

 cPanel Template Toolkit

<!-- Get a hash of all the data, then display the addon_domains values. -->
[% data = execute( 'DomainInfo', 'domains_data', { format => 'hash' } ); %]
[% FOREACH q = domains.data.addon_domains %]
     <p>
         [% q %]
     </p>
[% END %]
  
<!-- Get only the main_domain's domain name. -->
[% execute('DomainInfo', 'domains_data', { format => 'hash' }).data.main_domain.domain %]

 Output (JSON)

format=hash 

{
  "messages": null,
  "errors": null,
  "status": 1,
  "metadata": {
     
  },
  "data": {
    "addon_domains": [
      {
        "phpopenbasedirprotect": "1",
        "ip": "192.168.0.128",
        "domain": "seconddomain.com",
        "usecanonicalname": "Off",
        "group": "user",
        "hascgi": "1",
        "user": "user",
        "documentroot": "/home/user/public_html/seconddomain.com",
        "owner": "root",
        "userdirprotect": "",
        "ipv6": null,
        "serveralias": "seconddomain.com www.seconddomain.com www.seconddomain.example.com",
        "homedir": "/home/user",
        "servername": "seconddomain.example.com",
        "type": "addon_domain",
        "serveradmin": "webmaster@seconddomain.example.com",
        "no_cache_update": "0"
      },
      {
        "phpopenbasedirprotect": "1",
        "ip": "192.168.0.128",
        "domain": "exampledomain.com",
        "usecanonicalname": "Off",
        "group": "user",
        "hascgi": "1",
        "user": "user",
        "documentroot": "/home/user/public_html/subdomain",
        "owner": "root",
        "userdirprotect": "",
        "ipv6": null,
        "serveralias": "exampledomain.com www.exampledomain.com www.subdomain.example.com",
        "homedir": "/home/user",
        "servername": "subdomain.example.com",
        "type": "addon_domain",
        "serveradmin": "webmaster@subdomain.example.com",
        "no_cache_update": "0"
      },
      {
        "phpopenbasedirprotect": "1",
        "ip": "192.168.0.128",
        "domain": "addondomain.com",
        "usecanonicalname": "Off",
        "group": "user",
        "hascgi": "1",
        "user": "user",
        "documentroot": "/home/user/addondomain/home/dir",
        "owner": "root",
        "userdirprotect": "",
        "ipv6": null,
        "serveralias": "addondomain.com www.addondomain.com www.subdomain.example.com",
        "homedir": "/home/user",
        "servername": "subdomain.example.com",
        "type": "addon_domain",
        "serveradmin": "webmaster@subdomain.example.com",
        "no_cache_update": "0"
      }
    ],
    "parked_domains": [
      "parkeddomain.com"
    ],
    "sub_domains": [
      {
        "phpopenbasedirprotect": "1",
        "ip": "192.168.0.128",
        "domain": "sub.example.com",
        "usecanonicalname": "Off",
        "group": "user",
        "hascgi": "1",
        "user": "user",
        "documentroot": "/home/user/public_html/sub",
        "owner": "root",
        "userdirprotect": "",
        "ipv6": null,
        "serveralias": "www.sub.example.com",
        "homedir": "/home/user",
        "servername": "sub.example.com",
        "type": "sub_domain",
        "serveradmin": "webmaster@sub.example.com",
        "no_cache_update": "0"
      }
    ],
    "main_domain": {
      "phpopenbasedirprotect": "1",
      "options": "ExecCGI Includes",
      "ip": "192.168.0.128",
      "domain": "example.com",
      "hascgi": "1",
      "group": "user",
      "usecanonicalname": "Off",
      "scriptalias": [
        {
          "url": "/cgi-bin/",
          "path": "/home/user/public_html/cgi-bin"
        },
        {
          "url": "/cgi-bin/",
          "path": "/home/user/public_html/cgi-bin/"
        }
      ],
      "user": "user",
      "ifmodulemodsuphpc": {
        "group": "user"
      },
      "owner": "root",
      "documentroot": "/home/user/public_html",
      "userdirprotect": "",
      "serveralias": "parkeddomain.com www.parkeddomain.com www.example.com",
      "port": "80",
      "homedir": "/home/user",
      "customlog": [
        {
          "target": "/usr/local/apache/domlogs/example.com",
          "format": "combined"
        },
        {
          "target": "/usr/local/apache/domlogs/example.com-bytes_log",
          "format": "\"%{%s}t %I .\\n%{%s}t %O .\""
        }
      ],
      "servername": "example.com",
      "type": "main_domain",
      "serveradmin": "webmaster@example.com"
    }
  }
}

 format=list

 {

 

  "messages": null,

 

  "errors": null,

 

  "status": 1,

 

  "metadata": {

 

    "transformed": 1

 

  },

 

  "data": [

 

    {

 

      "phpopenbasedirprotect": "1",

 

      "options": "ExecCGI Includes",

 

      "ip": "192.168.0.128",

 

      "domain": "example.com",

 

      "hascgi": "1",

 

      "group": "user",

 

      "usecanonicalname": "Off",

 

      "scriptalias": [

 

        {

 

          "url": "/cgi-bin/",

 

          "path": "/home/user/public_html/cgi-bin"

 

        },

 

        {

 

          "url": "/cgi-bin/",

 

          "path": "/home/user/public_html/cgi-bin/"

 

        }

 

      ],

 

      "user": "user",

 

      "ifmodulemodsuphpc": {

 

        "group": "user"

 

      },

 

      "owner": "root",

 

      "documentroot": "/home/user/public_html",

 

      "userdirprotect": "",

 

      "serveralias": "parkeddomain.com www.parkeddomain.com www.example.com",

 

      "port": "80",

 

      "homedir": "/home/user",

 

      "customlog": [

 

        {

 

          "target": "/usr/local/apache/domlogs/example.com",

 

          "format": "combined"

 

        },

 

        {

 

          "target": "/usr/local/apache/domlogs/example.com-bytes_log",

 

          "format": "\"%{%s}t %I .\\n%{%s}t %O .\""

 

        }

 

      ],

 

      "servername": "example.com",

 

      "type": "main_domain",

 

      "serveradmin": "webmaster@example.com"

 

    },

 

    {

 

      "phpopenbasedirprotect": "1",

 

      "ip": "192.168.0.128",

 

      "domain": "seconddomain.com",

 

      "usecanonicalname": "Off",

 

      "group": "user",

 

      "hascgi": "1",

 

      "user": "user",

 

      "documentroot": "/home/user/public_html/seconddomain.com",

 

      "owner": "root",

 

      "userdirprotect": "",

 

      "ipv6": null,

 

      "serveralias": "seconddomain.com www.seconddomain.com www.seconddomain.example.com",

 

      "homedir": "/home/user",

 

      "servername": "seconddomain.example.com",

 

      "type": "addon_domain",

 

      "serveradmin": "webmaster@seconddomain.example.com",

 

      "no_cache_update": "0"

 

    },

 

    {

 

      "phpopenbasedirprotect": "1",

 

      "ip": "192.168.0.128",

 

      "domain": "exampledomain.com",

 

      "usecanonicalname": "Off",

 

      "group": "user",

 

      "hascgi": "1",

 

      "user": "user",

 

      "documentroot": "/home/user/public_html/subdomain",

 

      "owner": "root",

 

      "userdirprotect": "",

 

      "ipv6": null,

 

      "serveralias": "exampledomain.com www.exampledomain.com www.subdomain.example.com",

 

      "homedir": "/home/user",

 

      "servername": "subdomain.example.com",

 

      "type": "addon_domain",

 

      "serveradmin": "webmaster@subdomain.example.com",

 

      "no_cache_update": "0"

 

    },

 

    {

 

      "phpopenbasedirprotect": "1",

 

      "ip": "192.168.0.128",

 

      "domain": "addondomain.com",

 

      "usecanonicalname": "Off",

 

      "group": "user",

 

      "hascgi": "1",

 

      "user": "user",

 

      "documentroot": "/home/user/addondomain/home/dir",

 

      "owner": "root",

 

      "userdirprotect": "",

 

      "ipv6": null,

 

      "serveralias": "addondomain.com www.addondomain.com www.subdomain.example.com",

 

      "homedir": "/home/user",

 

      "servername": "subdomain.example.com",

 

      "type": "addon_domain",

 

      "serveradmin": "webmaster@subdomain.example.com",

 

      "no_cache_update": "0"

 

    },

 

    {

 

      "phpopenbasedirprotect": "1",

 

      "ip": "192.168.0.128",

 

      "domain": "sub.example.com",

 

      "usecanonicalname": "Off",

 

      "group": "user",

 

      "hascgi": "1",

 

      "user": "user",

 

      "documentroot": "/home/user/public_html/sub",

 

      "owner": "root",

 

      "userdirprotect": "",

 

      "ipv6": null,

 

      "serveralias": "www.sub.example.com",

 

      "homedir": "/home/user",

 

      "servername": "sub.example.com",

 

      "type": "sub_domain",

 

      "serveradmin": "webmaster@sub.example.com",

 

      "no_cache_update": "0"

 

    }

 

  ]

 

}

 

Note:

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

 

Parameters

 Parameter 

Type

Description

Possible values

 Example 

format

 string 

The function's return format.

 This parameter defaults to hash. 

  • hash — Use a hash format. This option returns the following hashes:
    • A hash that contains the addon_domains, parked_domains, andsub_domains arrays, each of which contain hashes for domains of those types. 
    • A main_domain hash that contains the main domain's information.
  • list — Use a list format. This option returns an array of hashes, with one hash per domain.

hash

 

 

Returns

Return

Type

Description

Possible values

Example

 addon_domains,parked_domains, orsub_domains 

Note:

The hash name indicates the type of domain.

array

An array that contains hashes of domain information for each domain of that type.

Note:

The function only returns output parameters in these hashes if you select thehash format.

 Each array's hashes may contain any of the return parameters below.

 

main_domain

hash

A hash that contains the main domain's information.

Note:

The function only returns output parameters in this hash if you select the hash format.

This hash may contain any of the return parameters below.

 

phpopenbasedirprotect

boolean

The domain's PHP open_basedir Tweaksetting.

  • 1 — Enabled.
  • 0 — Disabled.

1

ip

string

The domain's IP address.

An IP address.

                192.168.0.128

             

domain

string

The domain name.

A valid domain on the cPanel account.

example.com

usecanonicalname

string

The domain's Canonical Name (CNAME) setting.

  • On — Use the CNAME.
  • Off — Do not use the CNAME.

Off

group

string

The domain's group.

A group name.

user

hascgi

boolean

Whether CGI is enabled for the domain.

  • 1 — Enabled.
  • 0 — Disabled.

1

user

string

The cPanel account's username.

The cPanel account's username.

user

documentroot

string

The path to the domain's document root.

The absolute path to the domain's document root.

/home/user/public_html/example.com

owner

string

The cPanel account's owner.

The WHM account (root or a reseller) that owns the cPanel account.

root

userdirprotect

boolean

The domain's Apache mod_userdir Tweaksetting.

  • 1 — Enabled.
  • 0 — Disabled.

1

ipv6

string

The domain's IPv6 address.

  • null — The account does not use IPv6.
  • An IPv6 address.

2001:db8:28a0:2004:227:eff:fe1d:f770 

serveralias

string

A list of the domain's aliases.

A space-separated list of the domain's aliases.

seconddomain.com www.seconddomain.com www.seconddomain.example.com

homedir

string

The path to the account's home directory.

The absolute path to the account's home directory.

/home/user

servername

string

The domain's identifier on the server.

The domain's identifier on the server.

seconddomain.example.com

type

string

The domain type.

  • addon_domain — The domain is an addon domain.
  • sub_domain — The domain is a subdomain.
  • main_domain — The domain is the account's main domain.
  • parked_domain— The domain is a parked domain (domain alias).

addon_domain

serveradmin

string

The domain's administrator's contact email address.

A valid email address.

webmaster@seconddomain.example.com

no_cache_update

 boolean 

Whether the domain is subject to cache updates.

  • 1 — Cache updates.
  • 0 — No cache updates.

1

customlog

hash

A hash of Apache log information.

This hash contains the target andformat parameters.

 

target

string

The absolute path to the domain's log file.

The function returns this parameter in thecustomlog hash.

The absolute path to a location in the server's domlogsdirectory.

/usr/local/apache/domlogs/example.com

format

string

The target log file's format.

The function returns this parameter in thecustomlog hash.

An Apache log format.

Generally, this value is combined.

combined

 

  • 9 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....