All,
Using Keen.io to pull some analytics. I allow user input to specify start and end times, but I'm not able to find something equivalent to a "limit" parameter such as can be found for SQL queries. If a user specifies a large enough range, this can result in way too much data coming back.
Does Keen.io have a way to pull back the first "x" records?
bower.json
"keen-js": "^3.4.1",
There is a new Keen IO API feature released today which allows you to limit your query result to get your "top x results" and have the results ordered by ascending or descending as well. order_by
works similar to the currently existing group_by
feature -- you will call order_by
in your query.
Define a direction
to sort all of your query's results in either ASC
or descending order (default ordering is ascending). And use limit
to tell the API the number of results you'd like returned - whether that is your top 5 or bottom 5 results.
Order By Docs: https://keen.io/docs/api/#order-by
Here's sample JavaScript to illustrate the newly added order_by
API feature:
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', //this limits your number of results
timeframe: 'this_14_days'
})
.then(res => {
// Handle results
})
.catch(err => {
// Handle errors
});
order_by
and limit
has been a top requested by customers - thank you for feedback to help with creating tools and features to Keen IO's API.