apps/docs/list-memories/examples/pagination.mdx
Handle large memory collections efficiently using pagination to process data in manageable chunks.
// Get next page
const page2 = await client.documents.list({
limit: 20,
page: 2
});
console.log(`Page 1: ${page1.memories.length} memories`);
console.log(`Page 2: ${page2.memories.length} memories`);
```
# Get next page
page2 = client.documents.list(limit=20, page=2)
print(f"Page 1: {len(page1.memories)} memories")
print(f"Page 2: {len(page2.memories)} memories")
```
# Get next page
curl -X POST "https://api.supermemory.ai/v3/documents/list" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"limit": 20, "page": 2}'
```
while (hasMore) {
const response = await client.documents.list({
page: currentPage,
limit: 50
});
console.log(`Page ${currentPage}: ${response.memories.length} memories`);
hasMore = currentPage < response.pagination.totalPages;
currentPage++;
}
```
while has_more:
response = client.documents.list(page=current_page, limit=50)
print(f"Page {current_page}: {len(response.memories)} memories")
has_more = current_page < response.pagination.total_pages
current_page += 1
```