UAPI - Paginate Output

Introduction

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

1
2
3
4
5
6
7
paginate":{
"total_pages":1,
"total_results":1,
"current_page":1,
"results_per_page":100,
"start_result":"1"

Note:

You can test UAPI functions with pagination in cPanel's API Shell interface (Home >> Advanced >> API Shell). Click Show paginate/Filter/Paginate Options to display pagination options.

Pagination variables

UAPI pagination uses four basic variables:

Variable

Type

Description

Possible values

api.paginate

 boolean 

Whether to enable pagination.

  • 1 — Enable pagination.
  • 0 — Disable pagination.

 api.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 anapi.paginate_start value of 5. 

api.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 anapi.paginate_size value of 10.

api.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 anapi.paginate_page value of 2.

 

Examples

The following examples display paginated results for the  Email::list_lists  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.

cPanel or Webmail Session URL

/execute/Email/list_lists&api.paginate_start=5&api.paginate_size=10&api.paginate=1
/execute/Email/list_lists&api.paginate_start=5&api.paginate_size=10&api.paginate_page=2&api.paginate=1

LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Call the first page of mailing lists.
$paginated_visitors $cpanel->uapi(
    'Email''list_lists'
    array(
        'api.paginate'              => '1',
        'api.paginate_start'        => '5',
        'api.paginate_size'         => '10',
    
);
  
// Call the second page of mailing lists.
$paginated_visitors $cpanel->uapi(
    'Email''list_lists',
    array(
        'api.paginate'              => '1',
        'api.paginate_start'        => '5',
        'api.paginate_size'         => '10',
        'api.paginate_page'         => '2',
    )
);

LiveAPI Perl Class

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Call the first page of mailing lists.
my $paginated_visitors $cpliveapi->uapi(
    'Email''list_lists',
    {
        'api.paginate'              => '1',
        'api.paginate_start'        => '5',
        'api.paginate_size'         => '10',
    }
);
  
# Call the second page of mailing lists.
my $paginated_visitors $cpliveapi->uapi(
    'Email''list_lists',
    {
        'api.paginate'              => '1',
        'api.paginate_start'        => '5',
        'api.paginate_size'         => '10',
        'api.paginate_page'         => '2',
    }
);

cPanel Template Toolkit 

<!-- Call the first page of mailing lists. -->
[% execute('Email', 'list_lists', { 'domain' => 'example.com', 'api.paginate' => '1', 'api.paginate_start' => '5', 'api.paginate_size' => '10', }) %]
  
<!-- Call the second page of mailing lists. -->
[% execute('Email', 'list_lists', { 'domain' => 'example.com', 'api.paginate' => '1', 'api.paginate_start' => '5', 'api.paginate_size' => '10', 'api.paginate_page' => '2', }) %]

  • 8 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....