[comment]: # translation:outdated

[comment]: # ({669b84c5-669b84c5})
# 获取

[comment]: # ({/669b84c5-669b84c5})

[comment]: # ({2d20b586-b49a69bd})
### 描述

`integer/array trend.get(object parameters)`

该方法用于根据指定的参数检索趋势数据.

::: noteclassic
此方法适用于任何类型的用户， 调用方法的权限可以在用户角色设置中进行撤销，请参阅 [用户角色](/manual/web_interface/frontend_sections/administration/user_roles)了解更多信息.
:::

[comment]: # ({/2d20b586-b49a69bd})

[comment]: # ({ebb270d4-e33350ec})
### 参数

`(object)` 定义期望输出的参数.

该方法支持以下参数.

| 参数        | [类型](/manual/api/reference_commentary#data_types) | 描述                                      |
| ----------- | --------------------------------------------------- | ----------------------------------------- |
| itemids     | string/array                                        | 仅返回指定监控项ID的趋势.                 |
| time\_from  | timestamp                                           | 仅返回在给定时间之后或在给定时间收集的值. |
| time\_till  | timestamp                                           | 仅返回在给定时间之前或在给定时间收集的值. |
| countOutput | boolean                                             | 统计检索到的对象的数量.                   |
| limit       | integer                                             | 限制检索对象的数量.                       |
| output      | query                                               | 设置要输出的字段.                         |

[comment]: # ({/ebb270d4-e33350ec})

[comment]: # ({7223bab1-7223bab1})
### 返回值

`(integer/array)` 返回两者其中任一:

-    一个对象数组
-   如果已经使用了`countOutput`参数，则统计对象的数量.

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({a286419b-98fd9c3f})
#### 检索监控项趋势数据

请求:

```json
{
    "jsonrpc": "2.0",
    "method": "trend.get",
    "params": {
        "output": [
            "itemid",
            "clock",
            "num",
            "value_min",
            "value_avg",
            "value_max",
        ],
        "itemids": [
            "23715"
        ],
        "limit": "1"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

响应:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "23715",
            "clock": "1446199200",
            "num": "60",
            "value_min": "0.165",
            "value_avg": "0.2168",
            "value_max": "0.35",
        }
    ],
    "id": 1
}
```

[comment]: # ({/a286419b-98fd9c3f})

[comment]: # ({852a9753-852a9753})
### 源码

CTrend::get() in *ui/include/classes/api/services/CTrend.php*.

[comment]: # ({/852a9753-852a9753})
