Conflunce Cloud Rest Api Pagination and 'total' retrieval

Hi all,
The aim is to retrieve values from the Conf Cloud REST API and display the values in a paginated table (If there are thousands of results, it is not feasible to get all results when only displaying 1 page).

The 2 examples I have are retrieving Groups and Retrieving Users:

Users (Rest API Docs)

/wiki/rest/api/search?cql=type=user and user.fullname~<USERQUERY>&start=<START>&limit=<LIMIT>

This returns Json results, along with start , limit, size and totalSize.
The problem is totalSize ignores not retrieved values, and is exactly the same as size.
e.g.

/wiki/rest/api/search?cql=type=user and user.fullname~denny&start=0&limit=5

image
This shows 3 users, and as the limit was 5, all 3 users are returned.

However:

/wiki/rest/api/search?cql=type=user and user.fullname~denny &start=0&limit=2

image
Returns only 2 users for totalSize.
This means the true ‘total’ is not returned unless i loop through the max limit, each time counting the totalSize until totalSize < limit (No more results would be found).

This cannot be the most efficient method to retrieve all results?

Groups (Rest API Docs)

/wiki/rest/api/group/picker?query=<GROUP>&start=<START>&limit=<LIMIT>

This returns Json results, along with start, limit and size (If limit is reached, size and limit will be equal, otherwise size < limit as expected). Unlike the user retrieval, there is no totalSize.

TL:DR
When rendering results into Atlaskit DynamicTable, all rows are required. (Not feasible when there may be many thousands of results).
Because of this, I intend to render only the current page. This however requires knowing the total number of results for the pagination buttons (Page 1, Page 2 etc). Is there any way to achieve this at present that does not include looping through API calls, increasing start and limit until I have calculated the actual totalSize value?

2 Likes

Dear @DennyMiller .

I don’t have an answer for you but can confirm that I’m seeing the same issue. It seems to be dependent in the type. If you search for type=page you will get a proper totalSize. However when I search for type=page the start parameter is ignored - I can only use the provided next links. Does it work using the alternative REST endpoint “/rest/api/search/user”?

Best regards

Andreas

1 Like

Hi @andreas1 ,

Does it work using the alternative REST endpoint “/rest/api/search/user”?

Sadly, this also gives the same problem (set limit below the totalLimit, and I recieve the provided limit - It is only when I increase the limit to be higher than the known limit that the totalLimit is correct).

It is strange how you say type=page works. I have not tested this myself, but it is User cql i require, not page meta.

One other thing to note: Using the above example (Have 3 results returned, with a limit of 5), but if the start is set (e.g. 1), the totalLimit is now 1 lower than expected - Again, the total is being calculated from the returned values, not the actual values found.

1 Like