CubeJS
TradrAPI uses CubeJS under the hood to provide you with customisable and detailed reporting access to your data.
Using the CubeJS API is very easy as the functionality is builtin to the TradrAPI SDK.
Getting Started
Under the namespace admin.report
in the TradrAPI SDK, you will find two methods that you can use to interact with the
CubeJS API.
These are the query()
and the meta()
methods.
The query
method is used to run queries on the CubeJS API, while the meta
method is used to get metadata about the
available cubes and their dimensions and measures.
Authentication
To use the CubeJS API, you need to be authenticated. The same authentication credentials you use to access the TradrAPI SDK are used to authenticate you to the CubeJS API.
The level of access to the data from CubeJS is determined by the permissions your credentials have. If you have access to only one brand, you will only be able to query data for that brand.
Querying Metadata
To get metadata about the available cubes, dimensions and measures, you can use the meta
method.
const metadata = await tradrAPI.admin.report.meta();
Further information about the meta()
functionality can be found in the CubeJS meta docs (opens in a new tab).
Running Queries
To run queries, you can use the query
method.
const query = {
"measures": [
"Accounts.count"
],
"order": {
"Accounts.count": "desc"
},
"dimensions": [
"Groups.name"
],
"timeDimensions": [
{
"dimension": "Accounts.createdAt",
"granularity": "day"
}
]
};
const data = await tradrAPI.admin.report.query(query);
Further information about the query syntax can be found in the CubeJS queries docs (opens in a new tab) as well as the CubeJS query format docs (opens in a new tab).
The response format form the query()
method is a ResultSet
(opens in a new tab)
object. This object contains the data returned from the query as well as metadata about the query.
Direct access to the CubeJS API is also available via the TradrAPI SDK using the admin.report.cubeSdk()
method.
const cubeSdk = await tradrAPI.admin.report.cubeSdk();
Available Cubes
The available cubes related to broker
data are:
- Accounts
- BalanceTransactions
- Groups
- GroupBalances
- Orders
- Organizations
- Platforms
- Positions
- HistoricPositions
- Projects
- Servers
The available cubes related to prop
data are:
- Challenges
- Enrollments
- PropHistoricPositions
It is not currently possible to join data between broker
and prop
cubes in a single query.