Child pages
  • cPanel API 2 Functions - Ftp::listftpwithdisk
Skip to end of metadata
Go to start of metadata

Description

This function lists FTP users and their home directory's disk information.

Warning:

We strongly recommend that you use the following UAPI function instead of this function:

Important:

In cPanel & WHM version 76 and later, when you disable the FTP role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 WHM API (JSON)
https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=listftpwithdisk&include_acct_types=main


Note:

 For more information, read our Calls from the WHM API documentation.

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List the account's FTP users.
$list_ftpdisk = $cpanel->api2(
    'Ftp', 'listftpwithdisk',
 array(
        'include_acct_types' => 'main',
    ) 
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List the account's FTP users and disk information.
my $list_ftpdisk = $cpliveapi->api2(
    'Ftp', 'listftpwithdisk',
{ 
        'include_acct_types' => 'main',
    }
);


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Tag System (deprecated)


Warnings:

  • In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.
  • cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
  • For more information, read our Deprecated cPanel Tag Usage documentation.

 Command Line
cpapi2 --user=username Ftp listftpwithdisk include_acct_types=main


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • You must run the --user=username command.
  • For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.
  • If you run CloudLinux™, you must use the full path of the cpapi2 command:

    /usr/local/cpanel/bin/cpapi2

 Output (JSON)
{
  "cpanelresult": {
    "apiversion": 2,
    "func": "listftpwithdisk",
    "data": [
      {
        "diskquota": "unlimited",
        "diskusedpercent": 0,
        "diskused": 0,
        "humandiskquota": "None",
        "accttype": "main",
        "reldir": "",
        "_diskused": 0,
        "login": "example",
        "dir": "/home/example",
        "deleteable": 1,
        "serverlogin": "example",
        "htmldir": null,
        "humandiskused": "None",
        "diskusedpercent20": 0,
        "_diskquota": 0
      },
      {
        "diskquota": "unlimited",
        "diskusedpercent": 0,
        "diskused": 0,
        "humandiskquota": "None",
        "accttype": "logaccess",
        "reldir": "usr/local/apache/domlogs/example",
        "_diskused": 0,
        "login": "example_logs",
        "dir": "/usr/local/apache/domlogs/example",
        "deleteable": 1,
        "serverlogin": "example_logs",
        "htmldir": null,
        "humandiskused": "None",
        "diskusedpercent20": 0,
        "_diskquota": 0
      },
      {
        "diskquota": "unlimited",
        "diskusedpercent": 0,
        "diskused": 0,
        "humandiskquota": "None",
        "accttype": "sub",
        "reldir": "public_html/user",
        "_diskused": 0,
        "login": "user",
        "dir": "/home/example/public_html/user",
        "deleteable": 1,
        "serverlogin": "user@example.com",
        "htmldir": null,
        "humandiskused": "None",
        "diskusedpercent20": 0,
        "_diskquota": 0
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Ftp"
  }
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParametersTypeDescriptionPossible valuesExample
dirhtmlstring

A string to prepend to the dir return value.

This parameter defaults to the account's /home directory.

A valid string.example.com/
include_acct_typesstring

The types of account to view.

If you do not use this parameter, the function returns all FTP account types.

  • main — This is the main FTP account.
  • sub — This is a sub-user FTP account.
  • logaccess — This account is for logfile access.

Note:

Separate multiple types with the pipe (|) character.

                main
              
skip_acct_typesstring

The types of account to exclude.

If you do not use this parameter, the function does not exclude any FTP account types.

  • main — This is the main FTP account.
  • sub — This is a sub-user FTP account.
  • logaccess — This account is for logfile access.

Note:

Separate multiple types with the pipe (|) character.

                main
              

Returns

Return TypeDescriptionPossible valuesExample
diskquotastringThe account's disk quota, in Megabytes (MB).A positive integer value, or unlimited.
unlimited
diskusedpercentintegerThe percentage of space that the account uses.A positive integer value.0
diskusedintegerThe amount of space that the account uses, in Megabytes (MB).A positive integer value.0
humandiskquotastringThe amount of space that the account may use in a human-readable format, in Megabytes (MB).
  • None — For no space used.
  • A positive integer value, followed by MB.
None
accttypestringThe type of FTP account.
  • main — This is the main FTP account.
  • sub — This is a sub-user FTP account.
  • logaccess — This account is for logfile access.
sub
reldirstringThe relative path to the FTP user's document root.A valid relative path.
public_html/user
_diskusedintegerThe amount of space that the account uses, in bytes.A positive integer value.0
loginstringThe FTP account's username.A valid username.
user
dirstringThe path to the FTP user's document root.A valid absolute path.
/home/example/public_html/user
deleteableBooleanWhether you can delete the account.
  • 1 — You can delete this account.
  • 0 — You cannot delete this account.
1
serverloginstringThe full FTP login name.A username, at symbol (@), and the domain name
user@example.com
htmldirstringA null value.null is the only possible value.
null
humandiskusedstringThe amount of space that the account uses in a human-readable format, in Megabytes (MB).
  • None — The account uses no disk space.
  • A positive integer, a space, and the string MB.
None
diskusedpercent20integerThe percentage of space that the account uses.A positive integer value.0
_diskquotaintegerThe amount of space that the account may use, in bytes.A positive integer value.0
reasonstring

A reason for failure.

Note:

This function only returns a reason value if it failed.

A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1