# cPanel API 2 - Paginate Output

Warning:
The cPanel API 2 system is deprecated. We **strongly** recommend that you use [UAPI](/cpanel/introduction) instead of cPanel API 2.

## Introduction

You can use special variables to display cPanel API 2 output data in multiple pages (pagination). When you use pagination, the function's output's metadata includes the following hash of pagination control information:


```
paginate":{
"total_pages":1,
"total_results":1,
"current_page":1,
"results_per_page":100,
"start_result":"1"
}
```

Note:
You can test cPanel API 2 functions with pagination in cPanel's [*API Shell*](https://docs.cpanel.net/cpanel/advanced/api-shell-for-cpanel/) interface (*Home >> Advanced >> API Shell*). Click *Show paginate/Filter/Paginate Options* to display pagination options.

## Pagination variables

cPanel API 2 pagination uses four basic variables:

| Variable | Type | Description | Possible values |
|  --- | --- | --- | --- |
| `api2_paginate` | *Boolean* | Whether to enable pagination. | `1` — Enable pagination.`0` — Disable pagination. |
| `api2_paginate_start` | *integer* | The first record to display. | An integer value that represents a number of records. For example, begin the page's list of records with the fifth record, pass in an `api2_paginate_start` value of `5`. |
| `api2_paginate_size` | *integer* | The number of records to display. | An integer value that represents a number of records. For example, to display ten records on the page, pass in an `api2_paginate_size` value of `10`. |
| `api2_paginate_page` | *integer* | The page of results to display. | An integer value that represents which page of results to display. For example, to display the second page of records, pass in an `api2_paginate_page` value of `2`. |


## Examples

The following examples display paginated results for the [`Email::listpopswithdisk`](/cpanel-api-2/cpanel-api-2-modules-email/cpanel-api-2-functions-email-listpopswithdisk/) function.

* The example for the first page of results begins at the fifth record, and lists through the fourteenth record, to display a total of 10 records.
* The example for the second page of results begins at the fifteenth record, and lists through the twenty-fourth record, to display a total of 10 records.


**WHM API**


```
/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=listpopswithdisk&domain=example.com&api2_paginate_start=5&api2_paginate_size=10&api2_paginate=1
```


```
/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=listpopswithdisk&domain=example.com&api2_paginate_start=5&api2_paginate_size=10&api2_paginate_page=2&api2_paginate=1
```

Note:
For more information, read our [Use WHM API to Call cPanel API and UAPI](/whm/use-whm-api-to-call-cpanel-api-and-uapi) documentation.

**LiveAPI PHP Class**


```
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// Call the first page of recent visitors.
$paginateed_visitors = $cpanel->api2(
    'Stats', 'lastvisitors',
    array(
        'domain'                     => 'example.com',
        'api2_paginate'              => '1',
        'api2_paginate_start'        => '5',
        'api2_paginate_size'         => '10',
    )
);

// Call the second page of recent visitors.
$paginateed_visitors = $cpanel->api2(
    'Stats', 'lastvisitors',
    array(
        'domain'                     => 'example.com',
        'api2_paginate'              => '1',
        'api2_paginate_start'        => '5',
        'api2_paginate_size'         => '10',
        'api2_paginate_page'         => '2',
    )
);
```

Note:
For more information, read our [Guide to LiveAPI System](/guides/guide-to-the-liveapi-system/) documentation.

**LiveAPI Perl Class**


```
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# Call the first page of visitors.
my $paginated_visitors = $cpliveapi->api2(
    'Stats', 'lastvisitors',
    {
        'domain'                     => 'example.com',
        'api2_paginate'              => '1',
        'api2_paginate_start'        => '5',
        'api2_paginate_size'         => '10',
    }
);

# Call the second page of visitors.
my $paginated_visitors = $cpliveapi->api2(
    'Stats', 'lastvisitors',
    {
        'domain'                     => 'example.com',
        'api2_paginate'              => '1',
        'api2_paginate_start'        => '5',
        'api2_paginate_size'         => '10',
        'api2_paginate_page'         => '2',
    }
);
```

Note:
For more information, read our [Guide to LiveAPI System](/guides/guide-to-the-liveapi-system/) documentation.

**Command Line**


```
cpapi2 --user=username Stats lastvisitors api2_paginate=1 api2_pagiante_start=5 api2_paginate_size=10
```


```
cpapi2 --user=username Stats lastvisitors api2_paginate=1 api2_pagiante_start=5 api2_paginate_size=10 api2_paginate_page=5
```

**cPanel Tag System (deprecated)**


```
<?cp Email::listpopswithdisk (
          %[br],
          ip
          )
          domain="example.com",
          api2_paginate="1",
          api2_paginate_start="5",
          api2_paginate_size="10",
```


```
<?cp Email::listpopswithdisk (
          %[br],
          ip
          )
          domain="example.com",
          api2_paginate="1",
          api2_paginate_start="5",
          api2_paginate_size="10",
          api2_paginate_page="2",
?>
```

Warning:
* cPanel tags are **deprecated**. We **strongly** recommend that you **only** use the [LiveAPI](/guides/guide-to-the-liveapi-system) 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](/guides/guide-to-the-liveapi-system).
* 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](/cpanel-api-2/cpanel-api-2-deprecate-cpanel-tag-usage/) documentation.