Pagination issue in items

Hello @Matias.Monday ,
In my application, I am showing the items of all the boards of a particular workspace. but in pagination I am facing problem.

Example :- If Limit is 20 then API is returning 20 items of each board but we need only 20 records in a page.

API Details :-
{
“query”: “query { boards (ids: [123456789,1987654231]) { name type board_folder_id items_count items(newest_first: false limit: 10 page: 1 exclude_nonactive: true) {id name updated_at creator{id name}} } }”
}

Also below is the attached screenshot for your references.


Hello @manoranjan,

In this case, you should query the items for each individual board so that if, for example board A has 15 items and board B has 10 items, if your limit is 20, you first query for the items in board A, when the number of items in your response is lower than the limit, you can then calculate the difference and go to the next board and use that difference as the limit (in this case limit:5) which will give you 5 items from board B (after the 15 items from board A).

I hope that makes sense!

Cheers,
Matias

1 Like

Hello @Matias.Monday, Thanks for your reply. I am confused whatever you replied…so once again I elaborate my query.

We are facing an issue with the Monday API pagination.
Our requirement is to get all the items in a workspace which we are achieving by getting all the boards from the workspace ID and then passing the boards array to the below query to get all the items. But we need only 10 items as per our pagination limit. Below is our API query.

We provide ‘limit’ as 10 and ‘page’ as 1 so we expect 10 items out of all the items in the workspace.
But the response is not likewise. Response is returning 10 items per board and if we have multiple boards then the total number of returned items exceeds our limit i.e. 10! Please find the response of the query below.

As we can see the total number of returned items here is 14 which is unexpected as we have provided ‘limit: 10’.
Please guide us with some solution to this. Thanks in advance.

Hi @manoranjan!

In order to limit your response to 10 results in total, you’ll need to move your pagination parameters to the board query. Currently, this limitation is only being applied to the items sub-query.

1 Like

Hello @alessandra, Thanks for your reply.
We need the pagination for Items only not in board, then how to implement pagination in Items ?
Thanks.

Hello again @manoranjan,

If I understand correctly, you want to get (for example) 150 items from your boards.

Let’s say you have board A (100 items) and board B (100 items).

In that case, you would want to query for the 100 items in board A + the first 50 items in board B. Correct?

Instead of doing something like this:

query { boards (ids: [123456789,1987654231]) { name type board_folder_id items_count items(newest_first: false limit: 150 page: 1 exclude_nonactive: true) {id name updated_at creator{id name}} } }

You can do something like this:

query { boards (ids: 123456789) { name type board_folder_id items_count items(newest_first: false limit: 150 page: 1 exclude_nonactive: true) {id name updated_at creator{id name}} } }

using one board at a time. You then check how many items got retrieved. If your limit was 150, but you only got 100, because the board only has 100, you then go to the next board and use the limit 50 (because you already got 100 out of the 150 items you wanted):

query { boards (ids: 1987654231) { name type board_folder_id items_count items(newest_first: false limit: 50 page: 1 exclude_nonactive: true) {id name updated_at creator{id name}} } }

You need to do this because if you use pagination in the items and pass several boards, pagination will apply to each individual board.

Hope that makes sense!

Cheers,
Matias

1 Like