Pagination

How to paginate through API results

The Lirium API uses cursor-based pagination for resource collections.

Pagination Parameters

ParameterDescription
starting_afterReturn resources listed after the specified cursor value
ending_beforeReturn resources listed before the specified cursor value
limitMaximum number of results to return (page size)

Note: starting_after and ending_before are mutually exclusive. Only one may be used per request.

Response Format

All paginated responses include a pagination object:

{
  "pagination": {
    "starting_after": "20200901212845208267",
    "ending_before": "20200901213325502653",
    "limit": 10
  },
  "data": [
    ...
  ]
}

Navigation

  • Use starting_after from the response to navigate to the next page
  • Use ending_before from the response to navigate to the previous page

Empty Results

When there are no results, both starting_after and ending_before will be null.

To avoid losing your cursor position:

  • If using starting_after and you receive an empty response, there is no next page
  • If using ending_before and you receive an empty response, there is no previous page