Skip to content

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

ParameterWhat it isDefaultMaximum
pageThe page, starting at 11—
limitItems per page20100
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 }
}
FieldWhat it is
pageThe page returned
limitItems per page
totalHow many items exist, with filters already applied
totalPagesHow 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 limit that makes sense (up to 100) to make fewer calls.
  • Don't assume every list is paginated: when one isn't, the pagination block doesn't come back and data holds 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.