Get Asset DI Data Duration¶
Get the duration of different status (DI) data of specified devices within a certain period.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Read |
For more information about resources and required permission, see Policies, Roles and Permissions>>
Using GET Method¶
Request Format¶
GET https://{apigw-address}/tsdb-service/v2.0/di/duration
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
Mandatory |
String |
The organization ID which the asset belongs to. How to get orgId>> |
modelId |
Query |
Optional |
String |
The model ID. How to get modelID>> |
assetIds |
Query |
Mandatory |
String |
The asset ID. Supports the query of multiple asset IDs, separated by commas. How to get assetId>> |
measurepoints |
Query |
Mandatory |
String |
The measurement point ID. Supports the query of multiple measurement point IDs, separated by commas. How to get pointId>> |
startTime |
Query |
Mandatory |
String |
The start time of the sampling data, where both UTC and local time formats are supported.
|
endTime |
Query |
Mandatory |
String |
The end time of the sampling data. Its format must be consistent with |
status |
Query |
Optional |
String |
Filter results that include multiple status durations. For example, if only the results of status 0 are required, set the value as “0”. Multiple status are supported. Separate the status by commas. |
ifWithUnknown |
Query |
Optional |
Boolean |
|
Response Parameters ¶
Name |
Data Type |
Description |
---|---|---|
data |
List<JSONObject> |
The list of asset data. The data returned for a single point of a single device is sorted by the data timestamp in ascending order. For more information, see items |
items¶
Sample¶
{
"scanEndTimestamp": 1569859800000,
"measurepoint": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
]
}
Parameters¶
Name |
Data Type |
Description |
---|---|---|
scanEndTimestamp |
Long |
The timestamp of the last data to be scanned. The total number of data for one time scan must not exceed 640000. When the data exceeds 640000, the scan is stopped. This parameter returns the timestamp of the last data scanned, indicating the data after this timestamp are not included. |
assetId |
String |
The asset ID. |
measurepoint |
String |
The measurement point ID. |
durations |
List<JSONObject> |
A list of the durations of different statuses. |
status |
Integer |
The value of the measurement point of the device. |
duration |
Integer |
The duration of the above |
Error Codes¶
For description of error codes, see Common Error Codes.
Sample 1 (GET Method)¶
Request Sample¶
When ifWithUnknown
is true:
url: https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=yourOrgId&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&ifWithUnknown=true
method: GET
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
},
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
}
]
}
}
Sample 2 (GET Method)¶
Request Sample¶
When ifWithUnknown
is false:
url: https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=yourOrgId&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&ifWithUnknown=false
method: GET
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
},
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
}
]
}
}
Sample 3 (GET Method)¶
Request Sample¶
Filter the status
:
Note
After status
filtering, the status “Unknown” will be not inluded in the response.
url: https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=yourOrgId&assetIds=yourAssetIds&measurepoints=yourPointIds&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&status=1
method: GET
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
},
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
}
]
}
}
Using POST Method¶
Request Format¶
POST https://{apigw-address}/tsdb-service/v2.0/di/duration
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
orgId |
Mandatory |
String |
The organization ID which the asset belongs to. How to get orgId>> |
modelId |
Optional |
String |
he model ID. How to get modelID>> |
assetIds |
Mandatory |
String |
The asset ID. Supports the query of multiple asset IDs, separated by commas. How to get assetId>> |
measurepoints |
Mandatory |
String |
The measurement point ID. Supports the query of multiple measurement point IDs, separated by commas. How to get pointId>> |
startTime |
Mandatory |
String |
The start time of the sampling data, where both UTC and local time formats are supported.
|
endTime |
Mandatory |
String |
The end time of the sampling data. Its format must be consistent with |
status |
Optional |
String |
Filter results that include multiple status durations. For example, if only the results of status 0 are required, set the value as “0”. Multiple status are supported. Separate the status by commas. |
ifWithUnknown |
Optional |
String |
|
Response Parameters¶
See description in Response Parameters of the Using GET Method section.
Error Codes¶
For description of error codes, see Common Error Codes.
Sample 1 (POST Method)¶
Request Sample¶
When ifWithUnknown
is true:
url: https://{apigw-address}/tsdb-service/v2.0/di/duration
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"ifWithUnknown": true
}
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
},
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
}
]
}
}
Sample 2 (POST Method)¶
Request Sample¶
When ifWithUnknown
is false:
url: https://{apigw-address}/tsdb-service/v2.0/di/duration
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"ifWithUnknown": false
}
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
},
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
}
]
}
}
Sample 3 (POST Method)¶
Request Sample¶
Filter the status
:
Note
After status filtering, the status “Unknown” will be not inluded in the response.
url: https://{apigw-address}/tsdb-service/v2.0/di/duration
method: POST
Content-Type: multipart/form-data;charset=UTF-8
requestBody:
{
"orgId": "yourOrgId",
"assetIds": "yourAssetIds",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "1"
}
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
},
{
"scanEndTimestamp": 1569859380000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "yourPointId",
"assetId": "yourAssetId"
}
]
}
}
SDK Samples¶
You can access the `Java SDK Samples<https://github.com/EnvisionIot/sample-code-java/tree/EnOS2.4/tsdbdata>`__for TSDB data service on Github.