# DescribePrivateConnectTraffic

## 1. 接口描述

调用本接口用于查询二层网络专线在指定时间段内的带宽数据。

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

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

## 2. 请求参数

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

<table><thead><tr><th width="197">参数名称</th><th width="88">必选</th><th width="132.85945945945946">类型</th><th>描述</th></tr></thead><tbody><tr><td>privateConnectId</td><td>是</td><td>String</td><td>二层网络专线ID。</td></tr><tr><td>startTime</td><td>是</td><td><a href="../../../api-introduction/instruction/datatype">Timestamp</a></td><td><p>查询开始时间。</p><p>按照<code>ISO8601</code>标准表示，并且使用<code>UTC</code>时间。格式为：<code>YYYY-MM-DDThh:mm:ssZ。</code></p></td></tr><tr><td>endTime</td><td>否</td><td><a href="../../../api-introduction/instruction/datatype">Timestamp</a></td><td><p>查询结束时间。</p><p>按照<code>ISO8601</code>标准表示，并且使用<code>UTC</code>时间。格式为：<code>YYYY-MM-DDThh:mm:ssZ。</code><br><code>默认为当前时间。</code></p></td></tr></tbody></table>

## 3. 响应结果

<table><thead><tr><th width="226">名称</th><th width="186.97126156843643">类型</th><th>描述</th></tr></thead><tbody><tr><td>requestId</td><td>String</td><td><p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p></td></tr><tr><td>dataList</td><td>Array of <a href="../../datastructure#trafficdata">TrafficData</a></td><td>带宽数据列表。</td></tr><tr><td>in95</td><td>Float</td><td>入口带宽95值。</td></tr><tr><td>inAvg</td><td>Integer</td><td>入口带宽平均值。</td></tr><tr><td>inMax</td><td>Integer</td><td>入口带宽最大值。</td></tr><tr><td>inMin</td><td>Integer</td><td>入口带宽最小值。</td></tr><tr><td>inTotal</td><td>Integer</td><td>入口带宽总流量。</td></tr><tr><td>out95</td><td>Integer</td><td>出口带宽95值。</td></tr><tr><td>outAvg</td><td>Integer</td><td>出口带宽平均值。</td></tr><tr><td>outMax</td><td>Integer</td><td>出口带宽最大值。</td></tr><tr><td>outMin</td><td>Integer</td><td>出口带宽最小值。</td></tr><tr><td>unit</td><td>String</td><td>带宽值单位。例如：bps。</td></tr></tbody></table>

## 4. 代码示例

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

1. **查询实例一天内的流量数据。**

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

Request:
{
  "privateConnectId": "your-private-connect-id",
  "startTime": "2023-01-01T00:00:00Z",
  "endTime": "2023-01-01T23:59:59Z"
}

Response:
{
  "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
  "response": {
    "requestId": "T4C35327C-7B13-47B8-A815-5E5213D4A9F9",
    "dataList": [
      {
        "in": 873034,
        "out": 11971,
        "time": "2023-01-01T00:00:00Z"
      },
      {
        "in": 873034,
        "out": 11971,
        "time": "2023-01-01T00:05:00Z"
      },
      {
        "in": 635218,
        "out": 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"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

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

## 6. 错误码

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

<table><thead><tr><th width="157.9764821166095">HTTP状态码</th><th width="313">错误码</th><th>说明</th></tr></thead><tbody><tr><td>404</td><td>INVALID_PRIVATE_CONNECT_NOT_FOUND</td><td>指定的二层网络专线不存在。</td></tr><tr><td>403</td><td>INVALID_START_TIME_MUST_BEFORE_END_TIME</td><td>开始时间必须在结束时间之前。</td></tr><tr><td>403</td><td>INVALID_TIME_RANGE</td><td>无效的时间范围。查询跨度必须在一天之内。</td></tr><tr><td>403</td><td>TIME_OUT_OF_RANGE</td><td>查询的时间必须在30天之内。</td></tr><tr><td>403</td><td>INVALID_TIME_FORMAT</td><td>无效的时间格式。</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/api-reference/cn/networking/sdn/private-connect/describeprivateconnecttraffic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
