List With Groups
Get usage data with paginated groupings
client.v1.usage.listWithGroups(UsageListWithGroupsParamsparams, RequestOptionsoptions?): CursorPage<ending_beforestringgroup_keyuniongroup_valueunionstarting_onstringvalueunionUsageListWithGroupsResponse>
post/v1/usage/groups
Fetch aggregated usage data for the specified customer, billable-metric, and optional group, broken into intervals of the specified length.
Parameters
paramsbillable_metric_idstringcustomer_idstringwindow_sizeunionlimitnumbernext_pagestringcurrent_periodbooleanending_beforestringgroup_byGroupBystarting_onstringUsageListWithGroupsParams
Returns
UsageListWithGroupsResponse
import Metronome from '@metronome/sdk';
const client = new Metronome({
bearerToken: 'My Bearer Token',
});
// Automatically fetches more pages as needed.
for await (const usageListWithGroupsResponse of client.v1.usage.listWithGroups({
billable_metric_id: '222796fd-d29c-429e-89b2-549fabda4ed6',
customer_id: '04ca7e72-4229-4a6e-ab11-9f7376fccbcb',
window_size: 'day',
ending_before: '2021-01-03T00:00:00Z',
group_by: { key: 'region', values: ['US-East', 'US-West', 'EU-Central'] },
starting_on: '2021-01-01T00:00:00Z',
})) {
console.log(usageListWithGroupsResponse.ending_before);
}
200 Example
{
"data": [
{
"ending_before": "2019-12-27T18:11:19.117Z",
"group_key": "group_key",
"group_value": "group_value",
"starting_on": "2019-12-27T18:11:19.117Z",
"value": 0
}
],
"next_page": "next_page"
}