A new Keen IO API function has appeared, which allows you to limit the query result to get your “best results” and have results sorted in ascending or descending order. order_by works similarly to the currently existing group_by function - you will call order_by in your request.
Define direction to sort all of your query results in either ASC or descending order (default ascending order). And use limit to tell the API the number of results you would like to return - be it your 5 or 5 results.
The order of the documents: https://keen.io/docs/api/#order-by
Here's a JavaScript example to illustrate the recently added order_by API function:
import Keen from 'keen-js'; const client = new Keen({ projectId: 'PROJECT_ID', readKey: 'READ_KEY' }); client .query('count', { event_collection: 'logins', group_by: 'user.email', order_by: {'property_name': 'result', 'direction': 'DESC'}, limit: '5',
order_by and limit were requested by customers - thanks for the tip to help with the creation of the Keen IO API tools and features.
source share