限定数量查询设备事件

GET /api/devices/{deviceId}/events/latest

返回的数据是创建时间升序的,如果想查询时间段内所有数据,只需要以最后一条数据的创建时间作为下一次查询的起点就可以实现

返回的条数小于limit,表示已经是最后一页了,不需要继续查询

URL参数

参数名 类型 必填 描述 限制
deviceId string 设备唯一标识符
startDate Date 事件日期起,格式为:2019-11-14T16%3A25%3A00.000%2B0800,默认一天前
endDate Date 事件日期止,格式为:2019-11-14T16%3A25%3A00.000%2B0800,默认当前时刻
start Long 事件日期起,如果不传startDate就以start为准,start是精确到毫秒的时间戳
end Long 事件日期止,如果不传endDate就以end为准,end是精确到毫秒的时间戳
limitNum int 限制条数,最大1000

请求样例

GET /api/devices/146b3c23-55c7-4f24-bcb1-2c46cbae8370/events/latest?startDate=2019-11-15T13%3A25%3A00.000%2B0800&endDate=2019-11-15T16%3A25%3A00.000%2B0800&limitNum=2 HTTP/1.1
Host: zl.glodon.com
Authorization: Bearer xxx-xxxx-xxx
Cache-Control: no-cache

响应样例

{
  "returnCode": 0,
  "result": [
    {
      "createdTime": 1573803579000,
      "id": "146b3c23-55c7-4f24-bcb1-2c46cbae8370@#temp@#1573803579000",
      "tenantId": "b0d9addd-4221-4a7e-a49f-4615891d533f",
      "projectId": "e97e3c0e-1e17-4c61-9ef0-359eaea97de9",
      "modelId": "606840d4-a625-42ce-9885-3b43402aeb16",
      "deviceId": "146b3c23-55c7-4f24-bcb1-2c46cbae8370",
      "attributeCode": "temp",
      "attributeType": "Float",
      "attributeData": 2,
      "channel": "m",
      "ingressTimeStamp": 1573803579000,
      "deviceTimestamp": 1573803579000,
      "correlationId": "",
      "deleted": false
    },
    {
      "createdTime": 1573803579000,
      "id": "146b3c23-55c7-4f24-bcb1-2c46cbae8370@#windPower@#1573803579000",
      "tenantId": "b0d9addd-4221-4a7e-a49f-4615891d533f",
      "projectId": "e97e3c0e-1e17-4c61-9ef0-359eaea97de9",
      "modelId": "606840d4-a625-42ce-9885-3b43402aeb16",
      "deviceId": "146b3c23-55c7-4f24-bcb1-2c46cbae8370",
      "attributeCode": "windPower",
      "attributeType": "String",
      "attributeData": "3",
      "channel": "m",
      "ingressTimeStamp": 1573803579000,
      "deviceTimestamp": 1573803579000,
      "correlationId": "",
      "deleted": false
    }
  ]
}