---
title: Query the usage data for all meters (sparse)
slug: amberflo-api/query-the-usage-data-for-all-meters-sparse
docTags: 
createdAt: 2024-11-07T15:10:16.969Z
---

{
  "id": "RP0O5gZgYd7zWtqGFX9vj",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://app.amberflo.io/usage/sparse/all",
    "servers": [
      {
        "url": "https://app.amberflo.io/usage/sparse/all"
      }
    ],
    "name": "Query the usage data for all meters (sparse)",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "description": "",
            "customType": "usage.MeterAggregation.out[]",
            "schema": [
              {
                "name": "metadata",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/usage.MeterAggregationMetadata.out",
                "customType": "usage.MeterAggregationMetadata.out",
                "schema": [
                  {
                    "name": "account",
                    "kind": "optional",
                    "type": "string",
                    "example": ""
                  },
                  {
                    "name": "meterApiName",
                    "kind": "required",
                    "type": "string",
                    "description": "`meterApiName` as defined in [Meter API](ref:post_meters).",
                    "example": ""
                  },
                  {
                    "name": "aggregation",
                    "kind": "optional",
                    "type": "string",
                    "description": "Aggregation function. If not specified, the default is obtained from the associated meter definition.",
                    "modelRef": "#/components/schemas/usage.AggregationType.out",
                    "customType": "usage.AggregationType.out",
                    "schema": []
                  },
                  {
                    "name": "timeRange",
                    "kind": "required",
                    "type": "object",
                    "description": "Time period for which to compute the usage.",
                    "modelRef": "#/components/schemas/common.TimeRange.out",
                    "customType": "common.TimeRange.out",
                    "schema": [
                      {
                        "name": "startTimeInSeconds",
                        "kind": "required",
                        "type": "integer<int64>",
                        "description": "Start time, in [Unix time](https://en.wikipedia.org/wiki/Unix_time) (seconds).",
                        "example": 0
                      },
                      {
                        "name": "endTimeInSeconds",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "description": "End time, in [Unix time](https://en.wikipedia.org/wiki/Unix_time) (seconds). Defaults to \"now\".",
                        "example": 0
                      }
                    ]
                  },
                  {
                    "name": "filter",
                    "kind": "optional",
                    "type": "map",
                    "description": "`where` clause for the usage query. Each entry is a dimension and a list of values to filter for.\",\n\nValid filters are:\n- `customerId`\n- Any dimension defined in for the meter, see the [Meter API](ref:post_meters).\n- `tags:<tagId>`\n\nDifferent filters are combined using logical `AND` operator while different filter values for a given key are combined using logic `OR` operator.\n\nTags can be specified in filters using the prefix `tags:`. For example,\n\n1. `tags:stage = [prod, dev]` will filter usage by all customer having tag `stage.prod` **or** `stage.dev`\n2. `tags:stage = [prod], tags:region = [us-west]` will filter usage by customers having tags `stage.prod` **and** `region.us-west-2`.",
                    "example": "",
                    "customType": "map<string, string[]>",
                    "schema": []
                  },
                  {
                    "name": "groupBy",
                    "kind": "optional",
                    "type": "array",
                    "description": "Group the usage data by these dimensions. If unspecified or empty, data will be aggregated for the meter as a whole.\n\nValid values are:\n- `customerId`\n- `customerName`\n- Any dimension defined in for the meter, see the [Meter API](ref:post_meters).",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "take",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/usage.MeterAggregationMetadata.Take.out",
                    "customType": "usage.MeterAggregationMetadata.Take.out",
                    "schema": [
                      {
                        "name": "limit",
                        "kind": "required",
                        "type": "integer<int32>",
                        "example": 0
                      },
                      {
                        "name": "isAscending",
                        "kind": "optional",
                        "type": "boolean",
                        "example": ""
                      }
                    ]
                  },
                  {
                    "name": "timeGroupingInterval",
                    "kind": "optional",
                    "type": "string",
                    "description": "A usage query returns a time series of statistics. This field specifies the granularity of the time buckets in this series.\n\nNotice that for aggregation types: `MIN`, `MAX`, `AVG` this field has a more delicate meaning.\n\nFor example, for `AVG` if this field value is an `HOUR`, then you get the hourly average usage value for each group and a breakdown of each hour usage.\n\nOn the other hand if this field is a `DAY` then you get the average of the total daily usage, with a breakdown of the total usage per day.\n",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "customType": "com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "schema": []
                  },
                  {
                    "name": "valuesTimeGroupingInterval",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "customType": "com.amberflo.service.common.aggregation.AggregationInterval.out",
                    "schema": []
                  },
                  {
                    "name": "rescaleFunction",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.RescaleFunction.out",
                    "customType": "com.amberflo.service.common.aggregation.RescaleFunction.out",
                    "schema": [
                      {
                        "name": "function",
                        "kind": "optional",
                        "type": "string",
                        "description": "",
                        "modelRef": "#/components/schemas/com.amberflo.service.common.aggregation.RescaleFunctionType.out",
                        "customType": "com.amberflo.service.common.aggregation.RescaleFunctionType.out",
                        "schema": []
                      },
                      {
                        "name": "coefficient",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "clientMeters",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/usage.MeterAggregation.MeterAggregationGroup.out",
                "customType": "usage.MeterAggregation.MeterAggregationGroup.out[]",
                "schema": [
                  {
                    "name": "group",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "modelRef": "#/components/schemas/usage.MeterAggregation.GroupInfo.out",
                    "customType": "usage.MeterAggregation.GroupInfo.out",
                    "schema": [
                      {
                        "name": "groupInfo",
                        "kind": "optional",
                        "type": "map",
                        "example": "",
                        "customType": "map<string, string>",
                        "schema": []
                      }
                    ]
                  },
                  {
                    "name": "groupValue",
                    "kind": "optional",
                    "type": "number",
                    "example": ""
                  },
                  {
                    "name": "values",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "modelRef": "#/components/schemas/usage.MeterAggregation.AggregationValue.out",
                    "customType": "usage.MeterAggregation.AggregationValue.out[]",
                    "schema": [
                      {
                        "name": "value",
                        "kind": "optional",
                        "type": "number",
                        "example": ""
                      },
                      {
                        "name": "secondsSinceEpochUtc",
                        "kind": "optional",
                        "type": "integer<int64>",
                        "example": 0
                      }
                    ]
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/usage.MeterAggregation.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "zHfPA2UobBZtX2XA8kreI",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://app.amberflo.io/usage/sparse/all \\\n     --header 'accept: application/json'"
        },
        {
          "id": "v8XoC68om8tfNKBvCYwfm",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/usage/sparse/all\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "0WNKx2iKkcdw5xmo1A6mq",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/usage/sparse/all\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "ynuLoOwg9RDRFH4LQckII",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/usage/sparse/all\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "zHfPA2UobBZtX2XA8kreI"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful request\n[\n  {\n    \"metadata\": {\n      \"account\": \"\",\n      \"meterApiName\": \"\",\n      \"aggregation\": \"\",\n      \"timeRange\": {\n        \"startTimeInSeconds\": \"\",\n        \"endTimeInSeconds\": \"\"\n      },\n      \"filter\": \"\",\n      \"groupBy\": [\n        \"\"\n      ],\n      \"take\": {\n        \"limit\": \"\",\n        \"isAscending\": false\n      },\n      \"timeGroupingInterval\": \"\",\n      \"valuesTimeGroupingInterval\": \"\",\n      \"rescaleFunction\": {\n        \"function\": \"\",\n        \"coefficient\": 0\n      }\n    },\n    \"clientMeters\": [\n      {\n        \"group\": {\n          \"groupInfo\": \"\"\n        },\n        \"groupValue\": 0,\n        \"values\": [\n          {\n            \"value\": 0,\n            \"secondsSinceEpochUtc\": \"\"\n          }\n        ]\n      }\n    ]\n  }\n]"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}