Get Asset Raw Data by Time Range¶
获取指定设备的指定测点在某段时间内原始数据的值(包括AI、DI、和通用数据类型)。
使用GET方法¶
请求格式¶
GET https://{apigw-address}/tsdb-service/v2.0/raw
请求参数(URI)¶
名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|---|
orgId | Query | 必需 | String | 资产所属的组织ID。如何获取orgId信息>> |
modelId | Query | 可选 | String | 资产所属模型ID。如何获取modelId信息>> |
assetIds | Query | 必需 | String | 资产ID,支持查询多个资产,多个资产ID之间用英文逗号隔开。如何获取Asset ID信息>> |
measurepoints | Query | 必需 | String | 资产测点,支持多测点查询,各个测点间用英文逗号隔开。如何获取pointId信息>> |
startTime | Query | 必需 | String | 采样数据开始时间,支持local时间和UTC时间。local时间的格式为 YYYY-MM-DD HH:MM:SS 。当格式为local时间时,使用设备所在地的当地时间进行查询。UTC时间格式需要加入时区信息,例如:2019-06-01T00:00:00+08:00 。当格式为UTC时间时,对所有资产按照统一的开始时间和结束时间进行查询。 |
endTime | Query | 必需 | String | 采样数据结束时间,格式必须与开始时间保持一致。 |
pageSize | Query | 可选 | Integer | 单次查询返回记录条数的上限,默认为1000。 |
accessKey | Query | 可选 | String | 应用的服务账号,应用以accessKey进行鉴权以获得其被授权访问的数据。如何获取accessKey信息>> |
orderBy | Query | 可选 | String | 指定返回结果按照某字段排序,目前支持按 timestamp 字段排序。timestamp asc :按字段升序排序;timestamp desc :按字段倒序排序;默认值为 timestamp asc 。 |
withQuality | Query | 可选 | Boolean | 指定返回结果中是否包含数据质量位,true 表示包含数据质量位,false 表示不包含数据质量位,默认值为 false 。 |
localTimeAccuracy | Query | 可选 | Boolean | 指定查询结果是否包含毫秒级结果。true 表示需要毫秒格式,false 表示不需要毫秒格式,默认值为 false 。 |
响应参数 ¶
名称 | 数据类型 | 描述 |
---|---|---|
data | List<JSONObject> | 资产数据列表。单设备单点的返回数据按时间升序排列。详见 items |
items¶
示例¶
{
"assetId": "yourAssetId",
"timestamp": 1560249312446,
"yourPointId": 1.1236,
"localtime": "2019-06-11 18:35:12",
"quality": null
}
参数¶
名称 | 数据类型 | 描述 |
---|---|---|
assetId | String | 资产ID。 |
timestamp | Long | 数据时间戳,UNIX时间,精确到秒。 |
pointId | Double | 此参数是变量,在返回数据中显示为传入测点的标识符与查询到的测点数据。 |
localtime | String | 数据本地时间标记,精确到秒,当入参时间格式为UTC格式时,该值为null。 |
quality | Integer | 数据质量位 |
示例 1¶
请求示例¶
Local时间格式:
url: https://{apigw-address}/tsdb-service/v2.0/raw?orgId=yourOrgId&modelId=&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-05-26%2010:00:00&endTime=2019-06-28%2023:00:00&pageSize=&accessKey=accessKeyOfYourAPP
method: GET
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"assetId": "yourAssetId",
"timestamp": 1560249312446,
"yourPointId": 1.1236,
"localtime": "2019-06-11 18:35:12"
},
{
"localtime": "2019-06-12 16:49:29",
"yourPointId": "0",
"assetId": "yourAssetId",
"timestamp": 1560329369735
}
]
}
}
示例 2¶
请求示例¶
UTC时间格式:
url: https://{apigw-address}/tsdb-service/v2.0/raw?orgId=yourOrgId&accessKey=accessKeyOfYourAPP&modelId=yourModelId&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-06-01T00:00:00%2B08:00&endTime=2019-06-11T23:00:00%2B08:00&pageSize=100
method: GET
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"data": [
{
"localtime": null,
"assetId": "yourAssetId",
"yourPointId": 1.1236,
"timestamp": 1560249312446
},
{
"localtime": null,
"yourPointId": 0,
"assetId": "yourAssetId",
"timestamp": 1560329369735
}
]
}
}
示例 3¶
请求示例¶
带数据质量位的查询:
url: https://{apigw-address}/tsdb-service/v2.0/raw?orgId=yourOrgId&modelId=&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-05-26%2010:00:00&endTime=2019-06-28%2023:00:00&pageSize=&accessKey=accessKey&withQuality=true
method: GET
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"assetId": "yourAssetId",
"timestamp": 1560249312446,
"yourPointId": 1.1236,
"localtime": "2019-06-11 18:35:12",
"quality": 0
},
{
"localtime": "2019-06-12 16:49:29",
"yourPointId": 0,
"assetId": "yourAssetId",
"timestamp": 1560329369735,
"quality": 0
}
]
}
}
使用POST方法¶
请求格式¶
POST https://{apigw-address}/tsdb-service/v2.0/raw
请求参数(Body)¶
名称 | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|
orgId | 必需 | String | 资产所属的组织ID。如何获取orgId信息>> |
modelId | 可选 | String | 资产所属模型ID。如何获取modelId信息>> |
assetIds | 必需 | String | 资产ID,支持查询多个资产,多个资产ID之间用英文逗号隔开。如何获取Asset ID信息>> |
measurepoints | 必需 | String | 资产测点,支持多测点查询,各个测点间用英文逗号隔开。如何获取pointId信息>> |
startTime | 必需 | String | 采样数据开始时间,支持local时间和UTC时间。local时间的格式为 YYYY-MM-DD HH:MM:SS 。当格式为local时间时,使用设备所在地的当地时间进行查询。UTC时间格式需要加入时区信息,例如:2019-06-01T00:00:00+08:00 。当格式为UTC时间时,对所有资产按照统一的开始时间和结束时间进行查询。 |
endTime | 必需 | String | 采样数据结束时间,格式必须与开始时间保持一致。 |
pageSize | 可选 | String | 单次查询返回记录条数的上限,默认为1000。 |
accessKey | 可选 | String | 应用的服务账号,应用以accessKey进行鉴权以获得其被授权访问的数据。如何获取accessKey信息>> |
orderBy | 可选 | String | 指定返回结果按照某字段排序,目前支持按 timestamp 字段排序。timestamp asc :按字段升序排序;timestamp desc :按字段倒序排序;默认为 timestamp asc 。 |
withQuality | 可选 | String | 指定返回结果中是否包含数据质量位,true为包含,反之则不包含。 |
localTimeAccuracy | 可选 | String | 指定查询结果是否包含毫秒级结果。true 表示需要毫秒格式,false 表示不需要毫秒格式。 |
示例 1¶
请求示例¶
Local时间格式:
url: https://{apigw-address}/tsdb-service/v2.0/raw
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"measurepoints": "yourPointIds",
"startTime": "2020-04-20 00:00:00",
"endTime": "2020-04-21 00:00:00",
"pageSize": 1000,
"accessKey": "accessKey of your APP"
}
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"assetId": "yourAssetId",
"timestamp": 1560249312446,
"yourPointId": 1.1236,
"localtime": "2019-06-11 18:35:12"
},
{
"localtime": "2019-06-12 16:49:29",
"yourPointId": 0,
"assetId": "yourAssetId",
"timestamp": 1560329369735
}
]
}
}
示例 2¶
请求示例¶
UTC时间格式:
url: https://{apigw-address}/tsdb-service/v2.0/raw
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"measurepoints": "yourPointId1,yourPointId2",
"startTime": "2019-06-01T00:00:00%2B08:00",
"endTime": "2019-06-11T23:00:00%2B08:00",
"pageSize": 1000
}
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"data": [
{
"localtime": null,
"assetId": "yourAssetId",
"yourPointId1": 1.1236,
"timestamp": 1560249312446
},
{
"localtime": null,
"yourPointId2": 0,
"assetId": "yourAssetId",
"timestamp": 1560329369735
}
]
}
}
示例 3¶
请求示例¶
带数据质量位的查询:
url: https://{apigw-address}/tsdb-service/v2.0/raw
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"measurepoints": "yourPointIds",
"startTime": "2020-04-20 00:00:00",
"endTime": "2020-04-21 00:00:00",
"accessKey": "accessKey of your APP",
"withQuality": true
}
返回示例¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"assetId": "yourAssetId",
"timestamp": 1560249312446,
"yourPointId": 1.1236,
"localtime": "2019-06-11 18:35:12",
"quality": 0
},
{
"localtime": "2019-06-12 16:49:29",
"yourPointId": 0,
"assetId": "yourAssetId",
"timestamp": 1560329369735,
"quality": 0
}
]
}
}