REST API, pagination results

I’m building a REST API and I need to add paging data to the result, but I don’t know how to get to it…

If I type this, I see:

object(Cake\Datasource\Paging\PaginatedResultSet) id:0 {
protected results => object(Cake\ORM\ResultSet) id:1 { }
protected params => [
'sort' => 'Users.id',
'direction' => 'ASC',
'sortDefault' => 'Users.id',
'directionDefault' => 'ASC',
'completeSort' => [ ],
'perPage' => (int) 10,
'requestedPage' => (int) 1,
'alias' => 'Users',
'scope' => null,
'maxLimit' => (int) 100,
'limit' => null,
'count' => (int) 6,
'totalCount' => (int) 6,
'pageCount' => (int) 1,
'currentPage' => (int) 1,
'start' => (int) 1,
'end' => (int) 6,
'hasPrevPage' => false,
'hasNextPage' => false,
]
}

Or how do I properly have a paginator in the API endpoint output?

    public function index()
    {
        $paginateSettings = [
            'limit' => 10,
            'order' => ['Users.id' => 'ASC'],
        ];

        $users = $this->Users->find(
            'main',
            options: [
                'keyword' => $this->request->getQuery('keyword'),
            ]
        );

        $users = $this->paginate($users, $paginateSettings);

        $this->set([
            'users' => $users,
            'pagination' => []
        ]);

        $this->viewBuilder()
            ->setClassName('Json')
            ->setOption('serialize', ['users', 'pagination']);
    }