Pagination
Written by
Updated at October 1, 2024
Some API methods support pagination. Pagination is when a server returns results in parts, page by page, and not all of them at once. Pagination is generally used for the List*
method that returns a list.
To get the desired page with results, pass the following parameters in a request:
-
page_token
: Result page token. You can get the next page token from thenext_page_token
field when retrieving a list of resources (see the example below). -
page_size
: Number of results per page. Possible values: from 0 to 1000. The default value is: 100.
Examples
gRPC
gRPC description of the List
// The method returns a list of disks in the specified folder.
rpc List (ListDisksRequest) returns (ListDisksResponse) {
option (google.api.http) = { get: "/compute/v1/disks" };
}
message ListDisksRequest {
// Folder ID.
// Required field.
string folder_id = 1;
// Maximum number of results per page.
int64 page_size = 2;
// Token of the requested result page.
string page_token = 3;
}
message ListDisksResponse {
// List of disks.
repeated Disk disks = 1;
// Token of the next page.
string next_page_token = 2;
}
REST
Sample REST request used to get a list of disks in the folder:
GET https://compute.api.cloud.yandex.net/compute/v1/disks?folderId=a3s17h9sbq5asdgss12&pageToken=1acdeb26078146e6
Response:
{
"disks": [
{
"folderId": "de0m97h0gbq0foeuis03",
"createdAt": "2018-08-09T12:54:53+00:00",
"id": "de019dv504rmhoinn3nk",
"name": "development",
"zoneId" : "ru-central1-a",
"typeId" : "network-nvme",
"size" : 5368709120
},
...
],
"nextPageToken": "ae08rgjd5smu4bq5n1o4"
}