Handle large memory collections efficiently using pagination to process data in manageable chunks.

Basic Pagination

// Get first page
const page1 = await client.memories.list({
  limit: 20,
  page: 1
});

// Get next page
const page2 = await client.memories.list({
  limit: 20,
  page: 2
});

console.log(`Page 1: ${page1.memories.length} memories`);
console.log(`Page 2: ${page2.memories.length} memories`);

Loop Through Pages

let currentPage = 1;
let hasMore = true;

while (hasMore) {
  const response = await client.memories.list({
    page: currentPage,
    limit: 50
  });

  console.log(`Page ${currentPage}: ${response.memories.length} memories`);

  hasMore = currentPage < response.pagination.totalPages;
  currentPage++;
}
Use larger limit values (50-100) for pagination to reduce the number of API calls needed.