---
title: Querying Usage
slug: docs/get-usage-by-customer2
createdAt: 2024-07-16T13:32:05.084Z
---

## Query Usage data

Query the usage data scoped to the customer&#x20;

Usage API payload:

![](https://api.archbee.com/api/optimize/GQ6FhONXoR2DQjp03hOcB/rYpzSGkMGFO3e8AQTWnPV_image.png)

POST [https://app.amberflo.io/usage-java](https://app.amberflo.io/usage-java)

:::CodeblockTabs
usage

```json
{ // replace business_unit_id with customerId for a billing use case 
    "meterApiName": "ApiCalls",
    "aggregation": "SUM",
    "timeGroupingInterval": "Day",
    "timeRange": {
        "startTimeInSeconds": 1619293642
    },
    "filter": { "business_unit_id": ["xxx", "yyy"]},
    "groupBy": ["business_unit_id"],
    "take": {
        "limit": 10,
        "isAscending": false
    }
}
```
:::

API response breakdown:

![](https://api.archbee.com/api/optimize/GQ6FhONXoR2DQjp03hOcB/lrS-Ddq4k3NizRThZEMaO_image.png)

Sample API response:

:::CodeblockTabs
usage response

```json
{ // replace business_unit_id with customerId for a billing use case
    "metadata": {
        "account": null,
        "meterApiName": "ApiCalls",
        "aggregation": "sum",
        "timeRange": {
            "startTimeInSeconds": 1619294851,
            "endTimeInSeconds": 1619467650
        },
        "filter": {
            "business_unit_id": [
                "xxx",
                "yyy"
            ]
        },
        "groupBy": [
            "customerId"
        ],
        "take": {
            "limit": 10,
            "isAscending": false
        },
        "timeGroupingInterval": "day"
    },
    "secondsSinceEpochIntervals": [
        1619222400,
        1619308800,
        1619395200
    ],
    "clientMeters": [
        {
            "group": {
                "groupInfo": {
                    "business_unit_id": "xxx"
                }
            },
            "groupValue": 23645.0,
            "values": [
                {
                    "percentageFromPrevious": 0.0,
                    "value": 0.0,
                    "secondsSinceEpochUtc": 1619222400
                },
                {
                    "percentageFromPrevious": 100.0,
                    "value": 4040.0,
                    "secondsSinceEpochUtc": 1619308800
                },
                {
                    "percentageFromPrevious": 385.2722772277228,
                    "value": 19605.0,
                    "secondsSinceEpochUtc": 1619395200
                }
            ]
        },
        {
            "group": {
                "groupInfo": {
                    "business_unit_id": "yyy"
                }
            },
            "groupValue": 22608.0,
            "values": [
                {
                    "percentageFromPrevious": 0.0,
                    "value": 0.0,
                    "secondsSinceEpochUtc": 1619222400
                },
                {
                    "percentageFromPrevious": 100.0,
                    "value": 2507.0,
                    "secondsSinceEpochUtc": 1619308800
                },
                {
                    "percentageFromPrevious": 701.7949740725967,
                    "value": 20101.0,
                    "secondsSinceEpochUtc": 1619395200
                }
            ]
        }
    ]
}
```
:::

