Fetch aggregated event cardinalities per app (one auth token per app) over a date range, with optional cumulative sums.
In Moesif, Management API keys (tokens) are scoped per app for security. Even within the same organization, to fetch data across multiple apps for comparison you must obtain a separate Management API key for each app. Thus we created this script to fetch from different app and combine them into a single result.
- Node.js 18 or newer. Uses native HTTPS; no external dependencies required.
- One Management API key per app, each with at least the
READ EVENTSpermission.
node index.js \
--tokens TOKEN_FOR_APP1,TOKEN_FOR_APP2 \
--from 2025-10-28T21:35:47.000Z \
--to 2025-11-28T22:35:47.000Z \
--interval 1d \
--timeZone America/Los_Angeles \
--cumulative true
Optional: --baseUrl override (defaults to https://api.moesif.com/v1/search/~/count/events).
JSON printed to stdout:
{
"from": "2025-10-28T21:35:47.000",
"to": "2025-11-28T22:35:47.000",
"interval": "1d",
"timeZone": "America/Los_Angeles",
"cumulative": true,
"apps": [
{
"app": "appNameFromJwt",
"status": "ok",
"total_cardinality": 123,
"points": [
{
"key": "2025-11-01T00:00:00.000Z",
"cardinality": 5,
"cumulative": 5
}
]
}
]
}
- App name derived from JWT payload field
app, fallback toapp_idorapplication. - Cumulative values only present when
--cumulative true. - Errors per token included with
{ app, error }entries. statusvalues:ok(parsed),no-data(no aggregations but hits present),empty-response,unrecognized-format.