Counting the items from a group in PHP

My name is Lorentz and I have some questions about using PHP with monday. I am working with the monday API and I have connected my monday with PHP. But know I am looking for a way to count all the data that I have called in. The query that I made to get data is: query { boards (ids: xxxxxxxxx) { groups { title items { name id }}}}. This calls back all the items form all the groups. But I only want all the items from one specific group. And I also want to a piece of code the count all the items so that I have the total amount of items. Can someone give me a step in the right direction?

Hello @lorentz,

You can get items from a specific group by specifying the group id.
In your case, it will look like something like below:

query { boards (ids: xxxxxxxxx) { groups(ids: groupIdHere) { title items { name id }}}}

Concerning the number of items in a group, currently, as far as I’m aware, doesn’t offer a way to know how many items there are in a group. However, a hack you can use is to specify a high limit of items to return from the query and then when you receive the array of items, you can get the length of the items array.
For example:

query { boards (ids: xxxxxxxxx) { groups { title items(limit: 20000) { name id }}}}

You can read more about groups and items in the documentation

Hey @lorentz :wave:

Great question! And in my opinion, the response from @kolaai is exactly on point. You will need to specify the Group ID (or use an array of IDs as string, separated by comma).

We don’t offer an option to count the number of items via API currently, so that’s very accurate too.


Hello @AlexSavchuk, thank you for you quick response! But I have one more question to follow up on this. Do you any website or form or maybe you know your self how to use php to filter the data from the API?
EDIT: Is the data that you recieve also a array for PHP?

Thanks in advance.


I’m glad Alfred and I could help :slight_smile:

The response will be a JSON body. I’d recommend looking through how to filter JSON results in PHP generally. Here’s a StackOverflow thread that might be helpful:

Filter JSON in PHP