Pagination
How lists are split into pages with page and limit, the pagination block in the response, how to walk through everything and how filters and pagination combine.
Large lists (members, statement, feed, products) come in pages. You ask for a page with two parameters and get back, along with the items, the pagination block.
The parameters
| Parameter | What it is | Default | Maximum |
|---|---|---|---|
page | The page, starting at 1 | 1 | — |
limit | Items per page | 20 | 100 |
curl -s "https://api.memberfy.net/api/profiles/list?page=2&limit=50" \
-H "Authorization: Bearer $TOKEN" \
-H "X-CommunityId: $COMMUNITY_ID"
The response
{
"success": true,
"message": "…",
"data": [ { "…": "…" } ],
"pagination": { "page": 2, "limit": 50, "total": 137, "totalPages": 3 }
}
| Field | What it is |
|---|---|
page | The page returned |
limit | Items per page |
total | How many items exist, with filters already applied |
totalPages | How many pages there are |
Walking through everything
let page = 1;
const all = [];
while (true) {
const { data, pagination } = await api.profiles.getList({ page, limit: 100 });
all.push(...data);
if (page >= pagination.totalPages) break;
page += 1;
}
Filters and pagination
Filters (search, role, type, status…) are applied before paginating: total and totalPages only count what matches the filter.
Tips
- Use the largest
limitthat makes sense (up to 100) to make fewer calls. - Don't assume every list is paginated: when one isn't, the
paginationblock doesn't come back anddataholds everything. - When walking through a list that changes while you read it (the feed, for example), an item may show up on two pages; deduplicate by
id.