Charts through REST API

Hello everyone!

Is it possible to apply ‘group by’ to REST API search query? I know it is possible to group the result in Chart section, but I need to get grouped result also as a result of simple REST API query.

Same query in SQL for illustration:

SELECT custom_field, count(*) FROM table WHERE conditions GROUP BY custom_field;

Thank you very much.