> 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/sdn/cloud-router/describecloudrouterdctodctraffic.md).

# DescribeCloudRouterDCToDCTraffic

## 1. 接口描述

本接口(DescribeCloudRouterDCToDCTraffic)用于查询数据中心间流量。

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

* 可以通过[DescribeCloudRouters](https://github.com/zenlayer/zenlayercloud-api-doc-cn/tree/main/sdn/cloud-router/describe-cloud-routers.md)接口来获取三层网络中接入点的数据中心信息。
* 开始时间和结束时间的跨度不能超过一天。
* 只能查询30天内的流量数据。
* 该接口按数据中心聚合带宽，无法区分同一数据中心内多个接入点各自的流量。例如，查询数据中心A到Z的带宽，返回的是A中所有接入点到Z的总和，不能单独获取某个接入点到另一个接入点的带宽。
  {% endhint %}

## 2. 请求参数

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

| 参数名称            | 必选 | 类型                                                                          | 描述                                                                |
| --------------- | -- | --------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| cloudRouterId   | 是  | String                                                                      | 三层网络的 ID。                                                         |
| sourceDcId      | 是  | String                                                                      | 源数据中心 ID。                                                         |
| destinationDcId | 是  | String                                                                      | 目的数据中心 ID。                                                        |
| startTime       | 是  | String                                                                      | <p>查询开始时间。</p><p>ISO8601 格式，UTC 时区。</p>                           |
| endTime         | 否  | String                                                                      | <p>查询结束时间。</p><p>ISO8601 格式，UTC 时区，默认为当前时间。</p>                   |
| period          | 否  | Integer                                                                     | <p>数据采样周期。</p><p>单位为秒，可选值：20、40、60、120、300、900。</p><p>默认值：300</p> |
| statistic       | 否  | [TrafficStatistic](/api-reference/cn/sdn/datastructure.md#trafficstatistic) | <p>采样周期内流量数据的统计方式。</p><p>默认值：Average</p>                          |

## 3. 响应结果

| 参数名称      | 类型                                                                         | 描述                                                       |
| --------- | -------------------------------------------------------------------------- | -------------------------------------------------------- |
| requestId | String                                                                     | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| dataList  | Array of [TrafficData](/api-reference/cn/sdn/datastructure.md#trafficdata) | 流量明细数据列表。                                                |
| in95      | Integer                                                                    | 入方向 95 峰值流量。                                             |
| inAvg     | Integer                                                                    | 入方向平均流量。                                                 |
| inMax     | Integer                                                                    | 入方向最大流量。                                                 |
| inMin     | Integer                                                                    | 入方向最小流量。                                                 |
| out95     | Integer                                                                    | 出方向 95 峰值流量。                                             |
| outAvg    | Integer                                                                    | 出方向平均流量。                                                 |
| outMax    | Integer                                                                    | 出方向最大流量。                                                 |
| outMin    | Integer                                                                    | 出方向最小流量。                                                 |
| unit      | String                                                                     | <p>流量单位。</p><p>如 bps。</p>                                |

## 4. 代码示例

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

1. **查询三层网络中数据中心到数据中心一天内的流量数据。**

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

Request:
{
    "cloudRouterId": "your-cloudrouter-id",
    "sourceDcId": "source-dc-id",
    "destinationDcId": "destination-dc-id",
    "startTime": "2026-01-01T00:00:00Z",
    "endTime": "2026-01-01T23:59:59Z"
}

Response:
{
  "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
  "response": {
    "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
    "dataList": [
      {
        "time": "2026-01-01T00:00:00Z",
        "internetRX": 873034,
        "internetTX": 11971
      },
      {
        "time": "2026-01-01T00:05:00Z",
        "internetRX": 873034,
        "internetTX": 11971
      },
      {
        "time": "2026-01-01T00:10:00Z",
        "internetRX": 635218,
        "internetTX": 9028
      }
    ],
    "in95": 873034,
    "inAvg": 793762,
    "inMax": 873034,
    "inMin": 635218,
    "out95": 11971,
    "outAvg": 10990,
    "outMax": 11971,
    "outMin": 9028,
    "unit": "bps"
  }
}
```

2. **以 1 分钟为采样周期，查询三层网络中数据中心到数据中心一小时内每分钟的最大流量。**

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

Request:
{
  "cloudRouterId": "your-cloudrouter-id",
  "sourceDcId": "source-dc-id",
  "destinationDcId": "destination-dc-id",
  "startTime": "2026-01-01T00:00:00Z",
  "endTime": "2026-01-01T01:00:00Z",
  "period": 60,
  "statistic": "Maximum"
}

Response:
{
  "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
  "response": {
    "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
    "dataList": [
      {
        "internetRX": 912480,
        "internetTX": 12630,
        "time": "2026-01-01T00:00:00Z"
      },
      {
        "internetRX": 887215,
        "internetTX": 12104,
        "time": "2026-01-01T00:01:00Z"
      },
      {
        "internetRX": 701336,
        "internetTX": 9875,
        "time": "2026-01-01T00:02:00Z"
      }
    ],
    "in95": 912480,
    "inAvg": 833677,
    "inMax": 912480,
    "inMin": 701336,
    "out95": 12630,
    "outAvg": 11536,
    "outMax": 12630,
    "outMin": 9875,
    "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\_DATACENTER\_NOT\_FOUND | 指定的数据中心不存在。 |
