> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/traffic/bandwidth-cluster/describebandwidthclustertraffic.md).

# DescribeBandwidthClusterTraffic

## 1. 接口描述

本接口(DescribeBandwidthClusterTraffic)用于查询带宽组指定时间段内的流量信息。

{% hint style="info" %}
**注意事项**

* 开始时间和结束时间的跨度不能超过一天。
* 只能查询30天内的流量数据。
  {% endhint %}

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称               | 必选 | 类型                                                                                              | 描述                                                                                                                                                                                 |
| ------------------ | -- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bandwidthClusterId | 是  | String                                                                                          | 共享带宽包ID。                                                                                                                                                                           |
| startTime          | 是  | String                                                                                          | <p>查询开始时间。</p><p>按照ISO8601标准表示，并且使用UTC时间。</p><p>格式为：YYYY-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p>                          |
| endTime            | 是  | String                                                                                          | <p>查询结束时间。</p><p>按照ISO8601标准表示，并且使用UTC时间。</p><p>格式为：YYYY-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p>                          |
| city               | 否  | String                                                                                          | <p>按城市进行过滤，如LAX。</p><p>该值可以是城市英文名也可以是城市码。</p><p>指定该值，将会只返回该城市的带宽流量数据。</p><p>当前带宽组的城市码和城市名称可以在<a href="/pages/dQBHIhQ9dHmLI98h2zsm">DescribeBandwidthClusters</a>中的cities字段中查看。</p> |
| trafficType        | 否  | [BandwidthTrafficType](/api-reference/cn/compute/traffic/datastructure.md#bandwidthtraffictype) | <p>按流量类型进行过滤。</p><p>可选值：<code>LOCAL</code>（本地）、<code>INTERNATIONAL</code>（国际）。</p><p>仅 PathBasedBandwidth 类型的带宽包支持该参数。</p>                                                         |

## 3. 响应结果

| 参数名称                    | 类型                                                                                                                     | 描述                                                                                                                            |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| requestId               | String                                                                                                                 | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p>                                                                      |
| dataList                | Array of [BandwidthClusterTrafficData](/api-reference/cn/compute/traffic/datastructure.md#bandwidthclustertrafficdata) | 带宽数据列表。                                                                                                                       |
| in95                    | Integer                                                                                                                | 入口带宽95值。                                                                                                                      |
| in95Time                | String                                                                                                                 | <p>入口带宽95值时间。</p><p>格式为：YYYY-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p> |
| inAvg                   | Integer                                                                                                                | 入口带宽平均值。                                                                                                                      |
| inMax                   | Integer                                                                                                                | 入口带宽最大值。                                                                                                                      |
| inMin                   | Integer                                                                                                                | 入口带宽最小值。                                                                                                                      |
| inTotal                 | Integer                                                                                                                | 入口带宽总流量。                                                                                                                      |
| out95                   | Integer                                                                                                                | 出口带宽95值。                                                                                                                      |
| out95Time               | String                                                                                                                 | <p>出口带宽95值时间。</p><p>格式为：YYYY-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p> |
| outAvg                  | Integer                                                                                                                | 出口带宽平均值。                                                                                                                      |
| outMax                  | Integer                                                                                                                | 出口带宽最大值。                                                                                                                      |
| outMin                  | Integer                                                                                                                | 出口带宽最小值。                                                                                                                      |
| outTotal                | Integer                                                                                                                | 出口带宽总流量。                                                                                                                      |
| maxBandwidth95ValueMbps | Float                                                                                                                  | <p>最大带宽95值。</p><p>单位：Mbps。</p>                                                                                                |
| totalUnit               | String                                                                                                                 | <p>总流量单位。</p><p>例如：B。</p>                                                                                                     |
| unit                    | String                                                                                                                 | <p>带宽值单位。</p><p>例如：bps。</p>                                                                                                   |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1. 查询共享带宽包一天内的流量数据。**

```json
POST /api/v2/traffic HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: DescribeBandwidthClusterTraffic
<Common Request Params>

Request：
{
  "bandwidthClusterId": "bandwidthClusterId",
  "startTime": "2024-01-01T00:00:00Z",
  "endTime": "2024-01-01T23:59:59Z"
}

Response：
{
  "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
  "response": {
    "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
    "dataList": [
      {
        "internetRX": 873034,
        "internetTX": 11971,
        "time": "2024-01-01T00:00:00Z"
      },
      {
        "internetRX": 873034,
        "internetTX": 11971,
        "time": "2024-01-01T00:05:00Z"
      },
      {
        "internetRX": 635218,
        "internetTX": 9028,
        "time": "2024-01-01T00:10:00Z"
      }
    ],
    "in95": 873034,
    "in95Time": "2024-01-01T00:00:00Z",
    "inAvg": 793762,
    "inMax": 873034,
    "inMin": 635218,
    "inTotal": 89298270,
    "maxBandwidth95ValueMbps": 0.88,
    "out95": 11971,
    "out95Time": "2024-01-01T00:00:00Z",
    "outAvg": 10990,
    "outMax": 11971,
    "outMin": 9028,
    "outTotal": 1236457,
    "totalUnit": "B",
    "unit": "bps"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码                          | 说明         |
| ------- | ---------------------------- | ---------- |
| 404     | INVALID\_CLUSTER\_NOT\_FOUND | 指定的带宽组不存在。 |
