文档中心 > API类目 > 智慧园区API

alibaba.campus.device.openapi.gethistorydata (查询设备历史数据)

查询历史数据的接口

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
work_bench_context WorkBenchContext 必须 请求端信息
  • └ company_id
  • Number
  • 可选
  • 100000
  • 公司id
  • └ campus_id
  • Number
  • 必须
  • 100001
  • 园区id
query DeviceDataApiQuery 必须 历史数据查询对象
  • └ limit
  • Number
  • 必须
  • 20
  • 分页大小(最大500)
  • └ start_date
  • Date
  • 必须
  • 2018-01-29 00:00:00
  • 启始时间(防止接口超时,建议不要传入时间跨度过大,如查询一个月内的数据)
  • └ property_code
  • String
  • 必须
  • electric_p
  • 参数点code(详细请查阅‘平台技术’下‘设备详细信息开发文档’。)
  • └ end_date
  • Date
  • 必须
  • 2018-01-30 00:00:00
  • 终止时间
  • └ current_page
  • Number
  • 必须
  • 1
  • 当前页
  • └ uuid
  • String
  • 必须
  • b14a0b26-5745-4a85-97b1-5e2d0fbdc5bd
  • 设备id

响应参数

名称 类型 示例值 描述
result PageResult 出参
  • content
  • Page
  • 历史数据返回信息
  • └ total
  • Number
  • 1506
  • 总记录数
  • └ limit
  • Number
  • 20
  • 分页大小
  • results
  • DeviceDataApiDto []
  • 历史数据集合
  • └ device_id
  • String
  • b14a0b26-5745-4a85-97b1-5e2d0fbdc5bd
  • 设备id
  • └ device_code
  • String
  • 8-5-1电视机插座计量
  • 设备code
  • └ property_code
  • String
  • electric_p
  • 参数点code
  • └ value
  • String
  • 0.351
  • 历史数据值
  • └ timestamp
  • Number
  • 1517155225
  • 时间戳
  • └ value_type
  • Number
  • 20200
  • 值类型id
  • └ value_type_name
  • String
  • 数字型
  • 值类型名称
  • └ unit_id
  • Number
  • 31002
  • 单位id
  • └ unit_code
  • String
  • KW
  • 单位编码
  • └ current_page
  • Number
  • 1
  • 当前页
  • └ total_page
  • Number
  • 76
  • 总页数
  • └ error_code
  • String
  • 200
  • 错误码
  • └ error_msg
  • String
  • null
  • 错误信息
  • └ success
  • Boolean
  • success
  • 是否成功

请求示例

  • JAVA
  • .NET
  • PHP
  • CURL
  • Python
  • C/C++
  • NodeJS
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaCampusDeviceOpenapiGethistorydataRequest req = new AlibabaCampusDeviceOpenapiGethistorydataRequest();
AlibabaCampusDeviceOpenapiGethistorydataRequest.WorkBenchContext obj1 = new AlibabaCampusDeviceOpenapiGethistorydataRequest.WorkBenchContext();
obj1.setCompanyId(100000L);
obj1.setCampusId(100001L);
req.setWorkBenchContext(obj1);
AlibabaCampusDeviceOpenapiGethistorydataRequest.DeviceDataApiQuery obj2 = new AlibabaCampusDeviceOpenapiGethistorydataRequest.DeviceDataApiQuery();
obj2.setLimit(20L);
obj2.setStartDate(StringUtils.parseDateTime("2018-01-29 00:00:00"));
obj2.setPropertyCode("electric_p");
obj2.setEndDate(StringUtils.parseDateTime("2018-01-30 00:00:00"));
obj2.setCurrentPage(1L);
obj2.setUuid("b14a0b26-5745-4a85-97b1-5e2d0fbdc5bd");
req.setQuery(obj2);
AlibabaCampusDeviceOpenapiGethistorydataResponse rsp = client.execute(req);
System.out.println(rsp.getBody());

响应示例

  • XML示例
  • JSON示例
<alibaba_campus_device_openapi_gethistorydata_response>
    <result>
        <content>
            <total>1506</total>
            <limit>20</limit>
            <results>
                <device_data_api_dto>
                    <device_id>b14a0b26-5745-4a85-97b1-5e2d0fbdc5bd</device_id>
                    <device_code>8-5-1电视机插座计量</device_code>
                    <property_code>electric_p</property_code>
                    <value>0.351</value>
                    <timestamp>1517155225</timestamp>
                    <value_type>20200</value_type>
                    <value_type_name>数字型</value_type_name>
                    <unit_id>31002</unit_id>
                    <unit_code>KW</unit_code>
                </device_data_api_dto>
            </results>
            <current_page>1</current_page>
            <total_page>76</total_page>
        </content>
        <error_code>200</error_code>
        <error_msg>null</error_msg>
        <success>success</success>
    </result>
</alibaba_campus_device_openapi_gethistorydata_response>

异常示例

  • XML示例
  • JSON示例
<error_response>
    <code>50</code>
    <msg>Remote service error</msg>
    <sub_code>isv.invalid-parameter</sub_code>
    <sub_msg>非法参数</sub_msg>
</error_response>

错误码解释

错误码 错误描述 解决方案

API工具

如何获得此API

FAQ

返回
顶部