> 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/data-center-port/describeporttraffic.md).

# DescribePortTraffic

## 1. 接口描述

本接口(DescribePortTraffic)用于查询端口流量。

## 2. 请求参数

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

| 参数名称      | 必选 | 类型                                                                          | 描述                                                                                                                                       |
| --------- | -- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| portId    | 是  | String                                                                      | 数据中心端口 ID。                                                                                                                               |
| startTime | 是  | String                                                                      | <p>查询开始时间。</p><p>ISO8601 标准 UTC 格式：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 格式：YYYY-MM-DDThh<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</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. **查询数据中心端口一天的带宽数据**

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

Request: {
    "portId": "your-port-id",
    "startTime": "YYYY-MM-ddTHH:mm:ssZ",
    "endTime": "YYYY-MM-ddTHH:mm:ssZ"
}

Response:
{
  "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
  "response": {
    "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
    "dataList": [
      {
        "internetRX": 873034,
        "internetTX": 11971,
        "time": "2023-01-01T00:00:00Z"
      },
      {
        "internetRX": 873034,
        "internetTX": 11971,
        "time": "2023-01-01T00:05:00Z"
      },
      {
        "internetRX": 635218,
        "internetTX": 9028,
        "time": "2023-01-01T00:10:00Z"
      }
    ],
    "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: DescribePortTraffic
<Common Request Params>

Request:
{
  "portId": "your-port-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状态码 | 错误码 | 说明 |
| ------- | --- | -- |
