Simple way to determine if I can access the cPanel APIs?

Patanjali

Member
Apr 26, 2014
6
0
1
cPanel Access Level
Website Owner
I am a website owner with a retail account (not reseller).

I would like to know if I can access the cPanel APIs, particularly the Forwarder functions.

Is there a simple way to determine if I can access them?

I am not familiar with the intricacies of cPanel under the hood, so please don't assume I know all the technicals.


If it helps, I uploaded the PublicAPI files to my server, and ran the 'Using_the_LivePHP_Service.php' script, resulting in:

== Preparing Mock Server == = Please wait = Socket file does not exist: /tmp/php-connector-2yzc6du5oe.sock #0 /home/........./public_html/........./Cpanel/Examples/Using_the_LivePHP_Service.php(54): startExampleMockServer() #1 {main} EOF: You've successfully ended the Using_the_LivePHP_Service.php script.
which would seem to indicate that it couldn't contact the PHP engine.


Any help would be appreciated. Thanks.
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
If you have cPanel access, you have access to API1 and API2. If you have WHM access, you have access to the general XML/JSON API. You can test these with a URL.

To see if you have cPanel api access:

https://<your_server_name>:2083/<cpsess_name>/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=DomainLookup&cpanel_jsonapi_func=listdocroots

To see if you have WHM access:

https://<your_server_name>:2087/<cpsess_name>/json-api/listaccts

Please note that you will need to fill in your normal cPanel/WHM URL for <your_server_name> and you will need to log in to cPanel/WHM and copy the part of the URL that looks like /cpsessXXXXXXXX/ to <cpses_name>
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,250
463
Hello :)

Some hosting providers allow their cPanel users access to the "API Shell" feature documented here:

cPanel - API Shell

This can help you to formulate API function calls and provides a quick way of determining which functions are available to you. However, this feature is often not enabled by default, so the previous post is typically the best way of checking to see if an API function succeeds.

Thank you.
 

Patanjali

Member
Apr 26, 2014
6
0
1
cPanel Access Level
Website Owner
Thanks for the replies. Sorry I didn't get back earlier, but I had forgotten to subscribe to this thread, so I didn't know you had actually been very diligent!

To this:
https://<your_server_name>:2083/<cpsess_name>/json-api/cpanel?cpanel_jsonapi_version=2&cpanel_jsonapi_module=DomainLookup&cpanel_jsonapi_func=listdocroots
I get:
{"cpanelresult":{"apiversion":2,"func":"listdocroots","error":"Could not find function 'listdocroots' in module 'DomainLookup'","data":{"result":0,"reason":"Could not find function 'listdocroots' in module 'DomainLookup'"},"module":"DomainLookup"}}
What does that mean as far as API access goes? Does it mean I have some access, or am I just getting my hopes up?