jimlongo

Well-Known Member
Mar 20, 2008
253
21
68
What current API types are available to access WHM from an external app?
Primarily to get all domains (and subdomains) from an account. Might need to get userID from a main domain as well.

In this case WHMCS.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463

jimlongo

Well-Known Member
Mar 20, 2008
253
21
68
Thanks, every time I read about API1 it says deprecated, so I'm trying to stay with API2 so that the code won't break at some point.

Also unless I'm not seeing it I don't see anyway to get the subdomains and addonDomains for an account.


For instance I can authenticate using an APIToken (which is what I have available).
Using the example here

Can you tell me how I can construct a URL for a API2 or UAPI call with this authentication.

$user = "root";
$token = "MYAPITOKEN";
$query = "https://127.0.0.1:2087/json-api/listaccts?api.version=1";
 
Last edited:

jimlongo

Well-Known Member
Mar 20, 2008
253
21
68
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Thanks, every time I read about API1 it says deprecated, so I'm trying to stay with API2 so that the code won't break at some point.
Hello @jimlongo,

WHM API 1 is not deprecated. The deprecated APIs are WHM API 0, cPanel API 1, and cPanel API 2.

It would be a lot neater if one could use the UAPI DomainInfo:: list_domains function, but I don't see how to do that, yet.
If you're using WHM API 1 to call a cPanel UAPI function, you'd follow the guide below:

Use WHM API to Call cPanel API and UAPI - Developer Documentation - cPanel Documentation

For instance, to use UAPI per the above document, the URL would include the following:

Code:
cpanel_jsonapi_apiversion=3
Thank you.
 

jimlongo

Well-Known Member
Mar 20, 2008
253
21
68
Thanks for that cPanelMichael. Helpful as usual!

Using the APItoken for auth.

$header[0] = "Authorization: whm $user:$token";
here you can get the account(user) based on domain [using WHM API 1]. . .
https://mywhm.com:2087/json-api/listaccts?search={domain}&searchtype=domain&searchmethod=regex&want=user&api.version=1
and the domains based on account(user) [using UAPI] . . .
 
Last edited:
  • Like
Reactions: cPanelMichael
Thread starter Similar threads Forum Replies Date
R Developer Experience 4