I have a query using the analysis type count, I've got it grouped by type and it is returning me 12 different groups with varying values. Would it be possible to get only the 3 groups with the highest count from that query?
Asked
Active
Viewed 138 times
1 Answers
2
The Keen API doesn't (as of October 2015) support this directly, although it is a commonly requested feature. It may be added in the future but there is currently no timeline for that.
The best workaround is to do the sorting and trimming on the client side once the response has been received. This should only take a few lines of code in most programming languages. If you're working from a command line (e.g. via curl) then you could use jq to do it:
curl "https://api.keen.io/3.0/projects/...<insert your query URL>..." > result.json
cat result.json | jq '.result | sort_by(.result) | reverse | .[:3]'
Hope that helps! (Disclosure: I'm a platform engineer at Keen.)

Kevin Litwack
- 219
- 2
- 4