API Documentation
Cursor Pagination
The Leen API supports cursor-based pagination to help you efficiently navigate through large datasets. Follow these steps to implement pagination using our API.
Offset-based pagination is still supported on all of our list endpoints, but we recommend using cursor-based pagination for better performance and scalability. We will be deprecating offset-based pagination in future versions.
Currently supported endpoints:
Step 1: Enable Cursor Pagination
To enable pagination, include the query parameter enableCursor=true
in your initial request.
Step 2: Understand the Response
When pagination is enabled, the API response includes two keys:
next_cursor
: The cursor for the next page.previous_cursor
: The cursor for the previous page.
Here’s an example response:
Step 3: Use Cursors for Navigation
To navigate between pages, pass the appropriate cursor value in the cursor
query parameter:
- Next Page: Use
next_cursor
from the response. - Previous Page: Use
previous_cursor
from the response.
If you include the
updatedSince
filter in your first request, do not include the updatedSince
query parameter in subsequent requests that use a cursor
query parameter. Combining these parameters will cause the API to return a 422 error.Example Request
Step 4: Handle Edge Cases
- If
next_cursor
isnull
, you’ve reached the end of the dataset. - If
previous_cursor
isnull
, you’re at the beginning of the dataset.
By following these steps, you can seamlessly implement pagination in your application using the Leen API.
The
limit
parameter is unchanged and can still be used with cursor pagination to control the page size.