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.

curl -X GET "https://api.leen.dev/v1/vms/vulnerabilities" -d "enableCursor=true"

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:

{
  "items": [
    { ... },
    { ... }
  ],
  "next_cursor": "eyJvZmZzZXQiOjJ9",
  "previous_cursor": "eyJvZmZzZXQiOjB9"
}

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

curl -X GET "https://api.leen.dev/v1/vms/vulnerabilities" -d "enableCursor=true" -d "cursor=eyJvZmZzZXQiOjJ9"

Step 4: Handle Edge Cases

  • If next_cursor is null, you’ve reached the end of the dataset.
  • If previous_cursor is null, 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.