How to do aggregation by API in 4.x

Hello,
To help us, help you better we would need some more information. Check out this post for a better understanding .

Perhaps something in this post might help