Leaderboard
Get aggregated values grouped by common dimensions.
Use cases
Leaderboard visualization
Visualize leaderboard data in your apps.
Aggregated tables
Display aggregated data in tables.
Features
All the common API features, plus:
Group by dimensions
Group by dimensions
Group the results by one or more dimensions.
- Use
dimensions
in the query to specify the dimensions to group by
Ordering
Ordering
Order the results based on a sort direction.
- Use
sort
to specify the sort direction (ASC or DESC)
Row limit
Row limit
Limit the number of rows returned.
- Use
rowLimit
to specify the maximum number of rows to return
Example
Example 1: Simple leaderboard query
Get top 3 restaurants by total taco sales for the current year.
Usage
Arguments
The fields for querying a Metric in leaderboard format.
A Metric’s leaderboard query returns an ordered table of Dimension and Metric values over a given time range.
The Metric to query. You can query a pre-configured Metric by ID or name, or you can query an ad hoc Metric that you define inline.
The time range for calculating the leaderboard.
The time zone to use. Dates and times are always returned in UTC, but setting the time zone influences relative time ranges and granularities.
You can set this to “America/Los_Angeles”, “Europe/Berlin”, or any other value in the IANA time zone database. Defaults to “UTC”.
One or many Dimensions to group the Metric values by. Typically, Dimensions in a leaderboard are what you want to compare and rank.
The sort order of the rows. It can be ascending (ASC
) or descending (DESC
) order. Defaults to descending (DESC
) order when not provided.
The number of rows to be returned. It can be a number between 1 and 1,000.
The Query Filters to apply before retrieving the leaderboard data, in the form of SQL. If no Query Filters are provided, all data is included.
Response
The leaderboard response object. It contains an array of headers and a table (array of rows) with the selected Dimensions and corresponding Metric values for the given time range and Query Filters.
The table headers. It contains the Dimension and Metric names.
An ordered array of rows. Each row contains the Dimension values and the corresponding Metric value. A Dimension value can be empty. A Metric value will never be empty.
The Query statistics and metadata.