> 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/cdn/analysis/describebandwidth.md). Agents can also search and read this documentation through its [MCP server](https://docs.console.zenlayer.com/api-reference/~gitbook/mcp).

# DescribeBandwidth

## 1. 接口描述

本接口(DescribeBandwidth)用于查询cdn带宽，时间粒度是5分钟。

#### 准备工作

* 查询计费大区：调用[`DescribeBillingRegions`](https://docs.console.zenlayer.com/api-reference/cn/cdn/common/describebillingregions.md)。

## 2. 请求参数

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

| 参数名称      | 必选 | 类型     | 描述                                                                                                            |
| --------- | -- | ------ | ------------------------------------------------------------------------------------------------------------- |
| startTime | 是  | String | 获取数据起始时间点。日期格式按照 ISO8601 表示法，并使用 UTC 时间，格式为 yyyy-MM-ddTHH:flag\_mm:ssZ，例如2024-08-22T00:00:00Z                 |
| endTime   | 是  | String | 获取数据结束时间点。日期格式按照 ISO8601 表示法，并使用 UTC 时间，格式为 yyyy-MM-ddTHH:flag\_mm:ssZ，例如2024-08-22T00:10:00Z。结束时间点需要大于起始时间点。 |
| domain    | 否  | String | 加速域名，多个域名英文逗号间隔。默认查询所有加速域名                                                                                    |
| region    | 否  | String | [计费大区](https://docs.console.zenlayer.com/api-reference/cn/cdn/common/describebillingregions.md)               |
| protocol  | 否  | String | [协议类型](https://docs.console.zenlayer.com/api-reference/cn/cdn/datastructure.md#protocolvalue)                 |

## 3. 响应结果

| 参数名称      | 类型                                                                                                            | 描述                                         |
| --------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| dataSet   | Array of [BandwithData](https://docs.console.zenlayer.com/api-reference/cn/cdn/datastructure.md#bandwithdata) | 带宽(单位Mbps)。                                |
| requestId | String                                                                                                        | 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 requestId。 |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}

1. **查询cdn带宽。**

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

Request:
{
    "startTime": "2024-08-22T00:00:00Z",
    "endTime": "2024-08-22T01:00:00Z"
}
Response:
{
    "requestId": "T72DC2D08-XXXX-XXXX-XXXX-60567E6E53B8",
    "dataSet": [
        {
            "data": [
                {
                    "time": "2024-08-22T00:00:00Z",
                    "value": 4173.58
                },
                {
                    "time": "2024-08-22T00:05:00Z",
                    "value": 4792.3
                },
                {
                    "time": "2024-08-22T00:10:00Z",
                    "value": 4105.91
                },
                {
                    "time": "2024-08-22T00:15:00Z",
                    "value": 4373.59
                },
                {
                    "time": "2024-08-22T00:20:00Z",
                    "value": 5101.28
                },
                {
                    "time": "2024-08-22T00:25:00Z",
                    "value": 5980.99
                },
                {
                    "time": "2024-08-22T00:30:00Z",
                    "value": 5934.21
                },
                {
                    "time": "2024-08-22T00:35:00Z",
                    "value": 6283.05
                },
                {
                    "time": "2024-08-22T00:40:00Z",
                    "value": 6121.99
                },
                {
                    "time": "2024-08-22T00:45:00Z",
                    "value": 6609.52
                },
                {
                    "time": "2024-08-22T00:50:00Z",
                    "value": 6191.17
                },
                {
                    "time": "2024-08-22T00:55:00Z",
                    "value": 5513.65
                }
            ],
            "domain": "www.xxx.com",
            "region": "ALL"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## 5. 错误码

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