lmaitland

Member
Aug 17, 2013
7
0
1
cPanel Access Level
Root Administrator
Hello,

I have a question in relation to my cpanel WHM server.
Basically i was going to integrate a few of the API functions into my website.
I have a few questions in relation to this:

1. I'm guessing i will have to use the XML-API functions ( as my site will be separate from cpanel but on the same server)
2. Can i make an API only user account ( i have ssh'd into the server and made an account called api with a set password. How can i add access for this account to the api? )

Preferable id like to avoid doing anything with the root password so would rather keep it to a separate account.

Thanks,
Lewis
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

Could you elaborate on the purpose of having an account for API purposes only? Typically, API functions occurring for an individual account must occur with authentication as that account. You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script. Note the following document may also be useful:

cPanel XML and JSON APIs — cpanel

Thank you.
 

lmaitland

Member
Aug 17, 2013
7
0
1
cPanel Access Level
Root Administrator
Thank you for your response :)

The only reason for an API only account would be to isolate it from my root account so i dont have to put root passwords etc in my php files.

Is this possible or is the root details the only way.

Thank you,
Lewis
 

lmaitland

Member
Aug 17, 2013
7
0
1
cPanel Access Level
Root Administrator
Ok what ive done was just create a reseller hosting account on my server and im using that to do all the api calls.

I was going to use the function displaynews , and getpkginfo on my website to show the current news and information about my packages to people who are viewing the site. This means if i make a change to a package it will change it on the site.

Does anyone know if this is viable in terms of speed ( how costly is it to make lots of frequent api calls )

Thanks
 

hgrg

Well-Known Member
Oct 4, 2010
90
0
56
cPanel Access Level
Root Administrator
I'd do this:
dont query the api every time a page is loaded coz thats just crazy! Generate a status file(in json format for example < easy to parse with js on the client side..) instead and update it with a cronjob every X minutes/hours and you can load that file with ajax :)