Skip to main content
The IllumiChat API provides two pagination patterns depending on the endpoint and the nature of the data being returned. Offset-based pagination is used for static collections such as workspaces, assistants, and members. Cursor-based pagination is used for streaming or append-heavy data such as messages and webhook deliveries.

Offset-Based Pagination

Offset-based pagination uses limit and offset query parameters to control which slice of results is returned.
ParameterTypeDefaultDescription
limitinteger25Number of items to return. Minimum 1, maximum 100.
offsetinteger0Number of items to skip before starting to return results.

Response Shape

Every offset-paginated response includes the following top-level fields:
{
  "data": [
    { "id": "ws_abc123", "name": "Acme Corp" },
    { "id": "ws_def456", "name": "Globex" }
  ],
  "total": 48,
  "limit": 25,
  "offset": 0
}
FieldTypeDescription
dataarrayThe requested items for the current page.
totalintegerTotal number of items matching the query across all pages.
limitintegerThe limit that was applied.
offsetintegerThe offset that was applied.

Examples

curl -X GET "https://beta.illumichat.com/api/workspaces?limit=10&offset=20" \
  -H "Authorization: Bearer <your-api-key>"
To iterate through all pages, increment offset by limit on each request until offset >= total.

Iterating Through All Pages

async function fetchAll(baseUrl, token) {
  const items = [];
  let offset = 0;
  const limit = 100;

  while (true) {
    const res = await fetch(`${baseUrl}?limit=${limit}&offset=${offset}`, {
      headers: { Authorization: `Bearer ${token}` },
    });
    const { data, total } = await res.json();
    items.push(...data);
    offset += limit;
    if (offset >= total) break;
  }

  return items;
}

Cursor-Based Pagination

Cursor-based pagination uses an opaque cursor parameter and returns a nextCursor value. This pattern is more efficient for large, frequently changing datasets because it avoids the consistency issues inherent in offset-based pagination.
ParameterTypeDefaultDescription
limitinteger25Number of items to return. Minimum 1, maximum 100.
cursorstringnullOpaque cursor from a previous response. Omit to start from the beginning.

Response Shape

{
  "data": [
    { "id": "msg_aaa111", "content": "Hello" },
    { "id": "msg_bbb222", "content": "Hi there" }
  ],
  "nextCursor": "eyJpZCI6Im1zZ19iYmIyMjIifQ==",
  "hasMore": true
}
FieldTypeDescription
dataarrayThe requested items for the current page.
nextCursorstring or nullPass this value as the cursor parameter to fetch the next page. null when there are no more results.
hasMorebooleantrue if additional pages exist beyond the current result set.

Examples

# First page
curl -X GET "https://beta.illumichat.com/api/conversations/conv_abc/messages?limit=50" \
  -H "Authorization: Bearer <your-api-key>"

# Next page
curl -X GET "https://beta.illumichat.com/api/conversations/conv_abc/messages?limit=50&cursor=eyJpZCI6Im1zZ19iYmIyMjIifQ==" \
  -H "Authorization: Bearer <your-api-key>"
Cursor values are opaque and may change between API versions. Do not parse, construct, or store cursors for long-term use. Always obtain a fresh cursor from the most recent API response.

Choosing a Pattern

Use CasePatternReason
Listing workspaces, assistants, membersOffset-basedStable datasets; total count is useful for UI
Browsing messages in a conversationCursor-basedAppend-heavy data; avoids skipped or duplicated items
Webhook delivery logsCursor-basedHigh-volume, time-ordered data
Search resultsOffset-basedUsers expect page numbers and total counts
If an endpoint supports pagination, the documentation for that endpoint specifies which pattern is used. When in doubt, check the response shape: the presence of nextCursor indicates cursor-based pagination, while total and offset indicate offset-based pagination.