The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

API function to get account usage?

Discussion in 'cPanel Developers' started by fernandomm, Feb 2, 2011.

  1. fernandomm

    fernandomm Active Member

    Joined:
    Nov 25, 2009
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I have read the wiki page with Cpanel API functions but i could a function to get the account usage: disk space, email accounts, mysql databases etc.

    Is it possible to get this info somehow?

    Account summary only shows the account limits.

    Thanks!
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You are looking for StatsBar::stat:

    ApiStatsBar < ApiDocs/Api2 < TWiki

    you would call this like:

    /json-api/cpanel_jsonapi_module=StatsBar&cpanel_jsonapi_func=stat&display=diskusage|emailaccounts
     
  3. fernandomm

    fernandomm Active Member

    Joined:
    Nov 25, 2009
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I am trying to use this function with the same url that you showed, except that i am trying to specify user with &user=username.

    The issue is that i get this error: User parameter is invalid or was not supplied.

    And the error is strangely returned in xml format.
     
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    try cpanel_jsonapi_user as the parameter.
     
  5. fernandomm

    fernandomm Active Member

    Joined:
    Nov 25, 2009
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Matt,

    This function that you posted should be called at port 2083 with a user login, is that correct?

    In my case, i only have root access with access hash. Should i still call port 2083 or port 2087?

    Even after sending cpanel_jsonapi_user i get the same error ( yes, the account exists in server ).

    Any ideas?
     
  6. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can still do port 2087 with this, that's the only scenario where that is required, let me give a more exact example:

    :2087/json-api/cpanel?cpanel_jsonapi_user=cptest&cpanel_jsonapi_module=StatsBar&cpanel_jsonapi_func=stat&display=diskusage|sqldatabases|emailaccounts|ftpaccounts|bandwidthusage|parkeddomains|addondomains|subdomains


    This works on my server, if this is not working, please open a ticket at staff.cpanel.net/submit/ w/ credentials so that I can take a closer look and figure this out.
     
Loading...

Share This Page