On this page, you will learn how to use pagination with Blockberry API.
Specific resources contain more data than it is practical to return in a single request since it may cost a lot of computing power. API Pagination splits the data across multiple responses to fetch the queried data in the required volume, which helps you optimize your queries.
Several patterns are commonly used for implementing pagination in REST APIs. However, only two are used in Blockberry API: offset pagination (or page-based pagination) and cursor pagination.
Offset pagination
Offset pagination, or page-based pagination, is when an API endpoint accepts a parameter for a page number and breaks down the returned entries into pages. The size parameter specifies the number of returned entries on a page, while the page parameter specifies the page you’re querying. To query page 1, enter value 0 in the page field. Select ASC value in the orderBy field to get a list of returned entries in the order from the lowest to the highest value of the sorting parameter specified in the sortBy field (for instance, from the oldest to the latest transaction). Otherwise, select DESC (from the latest to the newest transaction).
![](https://files.readme.io/868f1a3-Pagination.png)
Cursor Pagination
Cursor pagination is when an API endpoint accepts a parameter for a cursor (a particular entity id: block state hash, transaction hash, address, coin type, etc.) and returns the following entries before or after it.
The nextCursor parameter specifies the particular entity (a coin, a transaction, an account, etc.) after or before which the entries will be returned. In contrast, the size parameter specifies the number of returned entries. If you select ASC in the orderBy field, the endpoint will return entries before (higher) the cursor value in the response according to the sorting parameter; otherwise, if you select DESC, the entries that go after (lower) the cursor value will be returned according to the sorting parameter.
![](https://files.readme.io/7520056-Pagination_2.png)