Skip to main content

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 the results by one or more dimensions.
  • Use dimensions in the query to specify the dimensions to group by
Order the results based on a sort direction.
  • Use sort to specify the sort direction (ASC or DESC)
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.
MetricInput
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.
TimeRangeInput
The time range for calculating the leaderboard.
String
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”.
[DimensionInput!]
required
One or many Dimensions to group the Metric values by. Typically, Dimensions in a leaderboard are what you want to compare and rank.
Sort
The sort order of the rows. It can be ascending (ASC) or descending (DESC) order. Defaults to descending (DESC) order when not provided.
Int
required
The number of rows to be returned. It can be a number between 1 and 1,000.
String
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.
[String!]
required
The table headers. It contains the Dimension and Metric names.
[[String]!]
required
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.
QueryInfo
required
The Query statistics and metadata.

Embeddable UI components

Leaderboard component

A React component for rendering leaderboard data.

useLeaderboard

A React Hook for fetching ranked data from the Leaderboard API.