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 to get list of databases for an account?

Discussion in 'cPanel Developers' started by simonpearce, Mar 8, 2009.

  1. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Hi,

    Is there a way to get a list of databases for an account?

    Thanks
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  3. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Simon,
    Yes, The MysqlFE::listdbs function should work fine for this, it can be called as follows:

    xml-api/cpanel?user=USERNAME&xmlin=%3Ccpanelaction%3E%3Cmodule%3EMysqlFE%3C/module%3E%3Cfunc%3Elistdbs%3C/func%3E%3C/cpanelaction%3E

    or in readable terms

    Code:
    <cpanelaction>
      <module>MysqlFE</module>
      <func>listdbs</func>
    </cpanelaction>
    
    this can be run either from WHM or cpanel. and will return something like:

    Code:
    <cpanelresult>
      <apiversion>2</apiversion>
      <data>
        <db>cptest_testing</db>
        <size>16384</size>
        <sizemeg>0.02</sizemeg>
        <usercount>0</usercount>
      </data>
      <func>listdbs</func>
      <module>MysqlFE</module>
    </cpanelresult>
    
     
  4. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Brilliant - thanks Matt!
     
  5. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Ah - am I right in thinking this can only be called from within cPanel?

    I need to be able to grab the list remotely?

    Cheers

    Simon
     
  6. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    156
    Thanks Matt - got it.

    Cheers

    (think one of our clocks is out a bit - threads is a bit mixed up!)
     
  7. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,277
    Likes Received:
    9
    Trophy Points:
    313
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can call this remotely via the XML API :).
     
Loading...

Share This Page