Pagination

Learn how pagination works in the Lia API - request parameters, response structure, Link headers, and best practices.

All list endpoints in the Lia API support pagination to help you efficiently retrieve large datasets. We use an enhanced hybrid pagination approach that combines pagination metadata in the response body with RFC 8288arrow-up-right Link headers for easy navigation.

Overview

Paginated endpoints return results in a consistent format with:

  • Response Body: Contains data array and detailed pagination metadata

  • Link Headers: Provides navigation URLs for first, previous, next, and last pages

Request Parameters

Use these query parameters to control pagination:

Parameter
Type
Default
Max
Description

page

integer

1

-

Page number to retrieve (1-indexed)

per_page

integer

50

100

Number of items per page

Response Structure

All paginated endpoints return responses in this format:

{
  "data": [...],
  "pagination": {
    "page": 1,
    "per_page": 50,
    "total_count": 150,
    "total_pages": 3,
    "has_next_page": true,
    "has_previous_page": false
  }
}

Pagination Metadata Fields

Field
Type
Description

page

integer

Current page number (1-indexed)

per_page

integer

Number of items per page

total_count

integer

Total number of items across all pages

total_pages

integer

Total number of pages available

has_next_page

boolean

Whether a next page is available

has_previous_page

boolean

Whether a previous page is available

In addition to the response body, paginated endpoints include RFC 8288 compliant Link headers for easy navigation:

Relation
Description

first

URL to the first page

prev

URL to the previous page (omitted on first page)

next

URL to the next page (omitted on last page)

last

URL to the last page

Examples

Basic Pagination Request

Retrieve the first page with default settings (50 items):

Custom Page Size

Retrieve 25 items per page:

Specific Page

Retrieve page 3:

Response Example

Code Examples

Error Handling

Invalid Page Number

If you request a page number that exceeds the total pages (and results exist), you'll receive a 400 Bad Request error:

Invalid Parameters

Invalid pagination parameters return validation errors:

Empty Results

When no results exist, you'll receive a successful response with empty data:

Last updated

Was this helpful?