Get all domains and subdomains

zerros

Registered
Jan 6, 2021
2
0
1
France
cPanel Access Level
Reseller Owner
Hi all. Forgive me for my bad english.

I use a web provider that gave me a cpanel account a few years ago. Actually, I have multiple resellers accounts managed by me. I'd like to get all domains and subdomains on each of them.

I use the uapi using a token for the main account but I can't get informations from each of resellers accounts. I have to create a toekn on each account to get datas.
Is there a way to get all datas from the main access like the switch context on the UI ?

Thanks.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
2,944
373
213
cPanel Access Level
Root Administrator
Hey there!

What about this command?

Code:
whmapi1 get_domain_info
This will return the following block of text for each domain on the server:

Code:
      docroot: /home/username/public_html
      domain: domain.com
      domain_type: main
      ipv4: 1.2.3.4
      ipv4_ssl: 1.2.3.4
      ipv6: ~
      ipv6_is_dedicated: 0
      modsecurity_enabled: 1
      parent_domain: domain.com
      php_version: ea-php72
      port: 80
      port_ssl: 443
      user: username
      user_owner: root
The user_owner field would tell you if this was owned by a certain reseller account.

Let me know if that works!
 

zerros

Registered
Jan 6, 2021
2
0
1
France
cPanel Access Level
Reseller Owner
I'm not root on the server. I don't have this command available. I use the UAPI from my laptop.
This is my code:


echo "############################"
echo "# List accounts"
echo "############################"
curl -qs -X POST -H "Authorization: cpanel $CPANEL_CREDENTIALS" "https://${URL}/execute/Resellers/list_accounts" | jq .

echo
echo "############################"
echo "# List domains"
echo "############################"
curl -qs -X POST -H "Authorization: cpanel $CPANEL_CREDENTIALS" "https://${URL}/execute/DomainInfo/list_domains" | jq .

echo
echo "############################"
echo "# Get usage"
echo "############################"
curl -qs -X POST -H "Authorization: cpanel $CPANEL_CREDENTIALS" "https://${URL}/execute/ResourceUsage/get_usages" | jq .

echo
echo "############################"
echo "# List domains for ACCOUNT1"
echo "############################"
curl -qs -X POST -H "Authorization: cpanel $ACCOUNT1_CREDENTIALS" "https://${URL}/execute/DomainInfo/list_domains" | jq .

echo
echo "############################"
echo "# List domains for ACCOUNT2"
echo "############################"
curl -qs -X POST -H "Authorization: cpanel $ACCOUNT2_CREDENTIALS" "https://${URL}/execute/DomainInfo/list_domains" | jq .

...
...


I'd like to access to all domains from the main account. I can change the context from the UI using a drop down menu. I don't know if I can do the same from the API.