Appearance
Analytics
Methods related to querying information about database statistics or aggregating information.
Quick Reference
| Method | Description |
|---|---|
| aggregateTransfers | Aggregate Transfers using either a simple filter or queryBuilder |
| getStatistics | Get aggregated statistics about WAPI entities |
aggregateTransfers
Aggregate Transfers using either a simple filter or queryBuilder
ts
await client
.aggregateTransfers()
.where({
type: 'deposit',
from_wallet: 'EUR',
to_wallet: 'house',
})
.whereMetadata('example', 'test')
.sum('to.amount as amount')
.count()
.groupBy('metadata.even as type', 'hour')
.options({
tracking_id: 'hello',
return_all_intervals: {
start_time: '2021-07-31 11:00:00',
end_time: '2021-07-31 13:00:00',
},
});ts
{
rows: [
{
amount: 25,
count: 5,
type: 'even',
hour: '2021-07-31 12'
},
{
amount: 30,
count: 5,
type: 'odd',
hour: '2021-07-31 12'
},
{
amount: null,
count: 0,
type: null,
hour: '2021-07-31 11'
},
{
amount: null,
count: 0,
type: null,
hour: '2021-07-31 13'
}
],
metadata: {
aggregators: [
{
function: 'sum',
field: 'to.amount',
alias: 'amount'
},
{
function: 'count',
alias: 'count'
}
],
groups: [
{
type: 'metadata_field',
field: 'even',
alias: 'type'
},
{
type: 'period',
field: 'hour',
alias: 'hour'
}
]
}
};aggregateTransfersFnInput
Input for aggregateTransfers
| Attribute | Type | Required | Description |
|---|---|---|---|
wallet | string | number | Foreign of the wallet connected to transfers | |
token | string | number | Foreign of the token transferred | |
from_wallet | string | number | Foreign of the wallet transfers are made from | |
to_wallet | string | number | Foreign of the wallet transfers are made to | |
transfer_group | string | number | Foreign of the transfer_group the transfers are a part of | |
status | | Status of the transfers | |
metadata | | Metadata filter | |
options | {} | Optional flags for input |
aggregateTransfersFnOutput
Output of aggregateTransfers
| Attribute | Type | Always | Description |
|---|---|---|---|
rows | | ✓ | Results of the aggregation |
metadata | {} | ✓ | Metadata about the aggregation |
getStatistics
Get aggregated statistics about WAPI entities
ts
await client.getStatistics(
{
model: 'Transfer',
aggregator: 'count',
group: 'month',
timezone: 'Europe/Tallinn',
filter: {
end_time: new Date(
`${new Date().getFullYear() + 1}-01-01`,
).toISOString(),
start_time: new Date(
`${new Date().getFullYear()}-01-01`,
).toISOString(),
},
},
{
// GENERALOPTIONS
},
);ts
{
rows: [
{
aggregate: 4,
period: '2026-01'
}
]
};getStatisticsFnInput
Input for getStatistics
| Attribute | Type | Required | Description |
|---|---|---|---|
model | | Model to return statistics about | |
aggregator | count | ||
group | | Time period rows should be grouped by | |
timezone | string | Timezones allowed | |
filter | {} | ||
options | {} | Optional flags for input |
getStatisticsFnOutput
Output of getStatistics
| Attribute | Type | Always | Description |
|---|---|---|---|
rows | ({})[] | ✓ |