Reports
Run Query
POST
https://{organisation}.clearlrs.com/api/reports/query
Runs an ad-hoc report query against the data stored in the system. The structure of this query is very flexible with the ability to target different data sources, filter and aggregate the data in numerous ways. The following documentation is not comprehensive but covers most major options.
Query Parameters
Name | Type | Description |
---|---|---|
limit | string | Limits the number of results returned |
skip | string | Skips over this number of items in query results |
Request Body
Name | Type | Description |
---|---|---|
expand | array | Performs a join on a secondary data source |
dataSource | string | The data source to query against |
filters | object | Restricts the data used in the query |
values | array | An Array of values that will be used as the columns output in the report |
group | array | Optional aggregation stages that describe how the output values should be combined |
sort | array | An Array of fields the report output should be sorted by |
Due to the powerful nature of this endpoint, it is possible to run queries across huge amounts of data which result in a very slow query. As such, it is recommended that filters are used to efficiently restrict the amount of data being queried.
Request Body
dataSource
dataSource
The following table outlines available data sources in Clear LRS. See the Data Sources section below for a list of available metrics for each data source.
Data Source | Description |
| Retrieves Users or Groups and their associated attributes |
| Retrieves all known activities from the system, this includes top-level activities as well as child activities |
| Point-in-time completion data for users broken down by their enrolments. Data won't exist unless the user is enrolled into the activity. |
| High-level completion data for users within a given top-level activity, broken into multiple attempts. |
| Fine-grained analytics data – this effectively encompasses all recorded data in the system. |
values
values
An Array of Objects composed of the following fields:
Field | Type | Description |
| String | The output name that the value will be mapped to. This would be the object key if JSON output or the column name if CSV. |
| String | The type of value to pull. Possible values are |
| String | The combination of |
| Array of Strings | When the data point required belongs to a nested field, use |
filters
filters
A recursive object that can be used to build complex filter conditions to restrict the data retrieved when generating a report. The structure of a the filter object is of a single key indicating the type of comparison to be performed, and an Array of operations to perform the comparison against.
and
– All operations in the Array must be met for the filter to match.or
– Any operation in the Array must be met for the filter to match.=
– The metric must match any of the values in the Array.!=
– The metric must not match any of the values in the Array.<
– The metric must be less than the second value in the Array.<=
– The metric must be less than or equal to the second value in the Array.>
– The metric must be greater than the second value in the Array.>=
– The metric must be great or equal to the second value in the Array.><
– The metric must be between the first and second values in the Array (non-inclusive).<>
– The metric must be less than the first value in the Array and greater than the second value in the Array (inclusive).exists
– A value for the metric must exist.!exists
– A value for the metric must not exist.
In the above example, the filter would retrieve all records where:
The
device
metric is equal to eithermobile
ordesktop
, AND;The user's
State
attribute is not equal toVIC
, OR;A value for the user's
Country
exists
group
group
An Array of Objects composed of the following fields:
Field | Type | Description |
| Array of Value Objects | The fields that this aggregation stage should be grouped by – multiple fields indicate that all unique combinations of these fields will be returned in the results. |
| Object | An object of key-value pairs that describe how each value from the values Array should be accumulated. The key must match the value's |
| Object | Optional additional filters to be applied after the aggregation has been processed. |
| Array | Optional additional sorting to be applied after the aggregation has been processed. |
Accumulator Types
When grouping on a field, it's necessary to specify an accumulator for all other values so the aggregator knows how to aggregate them together. The following are all available accumulators:
first
– Picks the first value in the result set. Should be used with a sort stage.last
– Picks the last value in the result set. Should be used with a sort stage.min
– Picks the greatest of all values in the result set.max
– Picks the least of all values in the result set.sum
– Calculates the total of all values in the result set.avg
– Calculates the average of all values in the result set.
In the above example, the group stage will calculate the sum
of all completions in the system, split by activity
and State
.
sort
sort
An Array of Objects composed of the following fields:
Field | Type | Description |
| String | The name of the output field to sort on. |
| Number | Specify |
Data Sources
status
status
Stability: Stable The metrics in this data source are unlikely to change and maintaining compatibility is a priority.
Type | Key / Key Path | Format |
|
| Serialised IFI |
|
| IRI |
|
| IRI |
|
| IRI |
|
| Number |
|
| Number |
|
| Number |
|
| Number |
|
| Number |
|
| Number |
|
| Number |
|
| String |
|
| UID |
|
| String |
|
| String |
|
| Array |
|
| Boolean |
|
| Date |
|
| Date |
|
| Date |
|
| Date |
completions
completions
Stability: Under Migration This is a legacy data source that is currently being migrated to a cleaner structure. Keys, Key Paths and the formats of some values are highly likely to change.
Type | Key / Key Path | Format |
|
| IRI xAPI Activity Id |
|
| UID Clear Agent ID |
|
| String
|
|
| Number
|
|
| Date |
|
| Date |
|
| Date |
|
| Date |
|
| Date |
analytics
analytics
Stability: Stable The metrics documented here are unlikely to change and maintaining compatibility is a priority. However, additional undocumented metrics may exist in this data source that are prone to change.
Type | Key / Key Path | Format |
|
| UUID Statement ID |
|
| Date |
|
| Date |
|
| Serialised IFI |
|
| String Actor's name |
|
| IRI |
|
| IRI |
|
| Array |
|
| Array |
|
| Array |
|
| Array |
|
| Array |
|
| IRI |
|
| IRI |
|
| Number |
Last updated