Sampled Data API
The Sampled Data API queries the sampled data for a list of tags. Data can be requested using a number of samples or a time range for a list of tags. If the count is not zero, the service returns the number of raw samples beginning from the start time. If the count is zero, the services uses the interval, start time, and end time to calculate the required sample number.
Note: For the query, you can also use optional parameters such as FilterMode and ReturnDataFields. Unused parameters can be omitted.
METHOD: | GET, POST |
URI: |
|
SAMPLE GET URI: | https://<historianservername>:8443/historian-rest-api/v1/datapoints/sampled?tagNames=tagName1&start=2013-10-02T11:30:00.111Z&end=2013-10-02T11:31:11.111Z&samplingMode=1&calculationMode=1&direction=0&count=0&intervalMs=1000 |
SAMPLE POST URI: | https://<historianservername>:8443/historian-rest-api/v1/datapoints/sampled |
SAMPLE cURL COMMAND (GET): | curl -i -H "Accept: application/json" -H "Authorization: Bearer <TOKEN> http://<nodename>:8443/ historian-rest-api/v1/ datapoints/sampled/<tagName>/<start time>/<end time>/<direction>/<count>/<intervalMS> |
SAMPLE cURL COMMAND (POST): | curl -i ?X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Authorization: Bearer <TOKEN> -d ?{ \ ?tagNames\ ?:\ ?<tagName>\ ?, \ ?start\ ?: \ ?<start>\ ?, \ ?end\ ?: \ ?<end>\ ?, \ ?samplingMode\ ?: <samplingMode>, \ ?calculationMode\ ?: <calculationMode>, \ ?direction\ ?: <direction>, \ ?count\ ?: <count>, \ ?returnDataFields\ ?: <returnDataFields>, \ ?intervalMs\ ?: <intervalMs>, \ ?queryModifier\ ?: <queryModifier>, \ ?filterMode\ ?: <filterMode>, \ ?filterExpression\ ?: \ ?<filterExpression>\ ?} http://<nodename>:8443/historian-rest-api/v1/datapoints/sampled |
Query Parameters
Parameter | Description | Required? | Values |
---|---|---|---|
TagNames | Queries the tag names specified. | Yes | String |
Start | Start time of the query, in ISO data format (such as YYYY-MM-DDTHH:mm:ss.SSSZ). | Yes | DateTime |
End | End time of the query, in ISO data format (such as YYYY-MM-DDTHH:mm:ss.SSSZ). | Yes | DateTime |
SamplingMode | Also known as SamplingModeType. | Optional | Integer, with a value such as 1. |
CalculationMode | Also known as CalculationModeType. | Optional | Integer, with a value such as 1. |
Direction | Specifies the direction (Forward or Backward from the starting time) of data sampling from the archive. The default value is Forward (0). | Optional | Integer, with a value such as 0. |
Count | The count of archive values within each calculation interval. | Optional | Integer, with a value such as 0. |
IntervalMS | Interval in milliseconds. | Optional | 64-bit signed integer, with a value such as 1000. |
Response Parameters
Parameter | Data Type | Required? | Description |
---|---|---|---|
ErrorCode | Integer | Yes | For example, 0. |
ErrorCode | String | Yes | For example, NULL. |
Data | String | Yes | The object container for the following parameters:
|
Sample Response
{
"ErrorCode" : 0,
"ErrorMessage": null,
"Data":[{
"DataType":"DoubleFloat",
"ErrorCode":0,
"TagName":"TagName1",
"Samples":[ { "TimeStamp":"2013-10-02T11:30:00.111Z","Value":"34.26155","Quality":3 },
{ "TimeStamp":"2013-10-02T11:30:10.111Z", "Value":"37.26155", "Quality":3 },
{ "TimeStamp":"2013-10-02T11:31:00.111Z", "Value":"33.26155", "Quality":3 }
]
}]
}