Step 1: Understand the Response

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 2: 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 3: 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.