Pagination

Pagination for the Reminix API

Several endpoints support pagination to retrieve large datasets efficiently.

Cursor-Based Pagination

The API uses cursor-based pagination for endpoints that return lists of items. This provides consistent results even when new items are added during pagination.

Request Parameters

ParameterTypeRequiredDescription
limitintegerNoNumber of items per page (default: 50, max: 100)
cursorstringNoPagination cursor from previous response

Response Format

Paginated responses include a cursor field in the response:

{
  "data": [
    // ... array of items
  ],
  "cursor": "eyJpZCI6ImV2dF8xMjM0NTY3OCIsInRpbWVzdGFtcCI6IjIwMjQtMDEtMTVUMTA6MzA6MDBaIn0",
  "hasMore": true
}

Pagination Flow

  1. First Request: Omit the cursor parameter to get the first page

    GET /v1/agents?limit=50
  2. Next Page: Use the cursor from the previous response

    GET /v1/agents?limit=50&cursor=eyJpZCI6ImV2dF8xMjM0NTY3OCIsInRpbWVzdGFtcCI6IjIwMjQtMDEtMTVUMTA6MzA6MDBaIn0
  3. Check for More: Use the hasMore field to determine if there are more pages

    • hasMore: true - More items available, use the cursor to fetch the next page
    • hasMore: false - No more items, you've reached the end

Example

let cursor: string | undefined
let allItems = []

do {
  const response = await reminix.list({
    limit: 50,
    cursor,
  })
  
  allItems.push(...response.data)
  cursor = response.cursor
} while (response.hasMore)

Best Practices

  • Use appropriate limit values: Balance between number of requests and response size
  • Handle empty responses: The data array may be empty even if hasMore is true
  • Don't modify cursors: Cursors are opaque strings - don't try to parse or modify them
  • Respect rate limits: Large pagination operations may hit rate limits