Common API Parameters
Overview of Commonly Used API Parameters
The Historian REST service provides various REST API calls to retrieve the current tags list and query data with different sampling modes. Most of these API calls use the following common parameters:
TagNames Parameter
https://<historianservername>:8443/historian-rest-api
/v1/datapoints/currentvalue?tagNames=tagName1;tagname2;tagname3
Encode the semicolon as %3B
if using the URI format, as the semicolon is also a valid character for a Historian name, and the web service parses the tag names incorrectly if a tag name contains a semicolon.
Start and End Timestamps Parameter
For the Start and End Timestamps parameter, the Timestamp format in the URI must be in ISO data format, such as YYYY-MM-DDTHH:mm:ss.SSSZ
.
EPOCH time (standard base time) is only valid in the JSON-format request body or response body, such as \/Date(928167600000-0500)\/
. If you use the same timestamp for start and end timestamps, the request returns a single result.
All timestamps passed to the REST service must be formatted as UTC timestamps.
Object Name | Description |
---|---|
StartTime | Start time of the query. This represents the earliest timestamp for any tag contained in the query. If no StartTime is specified, the start time is two hours prior to running the query. |
EndTime | End time of the query. This represents the latest timestamp for any tag contained in the query. If no EndTime is specified, the end time is the time that the query runs. |
TagSamples Parameter
Property Name | Property Type | Description |
---|---|---|
TagName | String | Name of the tag. |
DataType | String | Tag Data Type Value:
|
ErrorCode | Error Code | Error Code Definition See Error Code Definition for more information. |
Samples | Data Sample | See DataSample Parameter for more information. |
DataSample Parameter
Property Name | Property Type | Description |
---|---|---|
Value | String | Format for a multi-field tag like { "field1":"1","field2":"1000.0" } (user-defined type tag).JavaScript code can parse the value string as a JSON object. All field values are string. |
TimeStamp | DateTime | Start and end times of the query. If no start time is specified, the start time is two hours prior to running the query. If no EndTime is specified, the end time is the time the query runs. |
Quality | Integer (Enumerated value of DataQuality.StatusType) |
Data type consisting of a set of named values called elements, members or enumerators of the type. Property values reflect quality as "quality is good" or " quality is bad".
|
SamplingModeType Parameter
Calculated
.
Properties | Description | Value |
---|---|---|
Undefined | Sampling mode is not defined. | 0 |
CurrentValue | Retrieves the current value. The time- interval criteria are ignored. | 1 |
Interpolated | Retrieves evenly-spaced, interpolated values based on interval or NumberOfSamples and the time-frame criteria. | 2 |
Trend | Returns the raw minimum and raw maximum value for each specified interval. Use the Trend sampling mode to maximize performance when retrieving data points for plotting. For the Trend sampling mode, if the sampling interval does not evenly divide by the interval length, Historian ignores any leftover values at the end, rather than putting them into a smaller interval. | 3 |
RawByTime | Retrieves raw archive values based on time-frame criteria. | 4 |
RawByNumber | Retrieves raw archive values based on the StartTime criteria, the NumberOfSamples, and Direction criteria. The EndTime criteria is ignored for this sampling mode. | 5 |
Calculated | Retrieves evenly spaced calculated values based on NumberOfSamples, interval, the time frame criteria, and the CalculationMode criteria. | 6 |
Lab | Returns actual collected values without interpolation. | 7 |
InterpolatedtoRaw | Provides raw data in place of interpolated data when the number of samples are fewer than the available samples. | 8 |
TrendtoRaw | The TrendtoRaw sampling mode almost always produces the same results as the Trend sampling mode. However, when more samples are requested than there are raw data points, the TrendtoRaw sampling mode returns all available raw data points with no further processing. Use TrendtoRaw in place of Trend when this condition exists. | 9 |
LabtoRaw | Provides raw data for the selected calculated data, when NumberOfSamples is less than the available samples. | 10 |
RawByFilterToggle | Returns filtered time ranges using the following values:
This sampling mode is used with the time range and filter tag conditions. The response string starts with a starting time stamp and ends with an ending timestamp. |
11 |
Direction Parameter
Direction | Value |
---|---|
Forward | 0 |
Backward | 1 |
CalculationModeType Parameter
Calculation Mode Type | Description | Value |
---|---|---|
Undefined | Calculation mode is not defined. | 0 |
Average | Retrieves the time-weighted average for each calculation interval. | 1 |
StandardDeviation | Retrieves the time-weighted standard deviation for each calculation interval. | 2 |
Total | Retrieves the time-weighted rate total for each calculation interval. Use rate totals when working with a continuous measurement. Time weighting takes into account that compressed data is not evenly spaced in time. A factor must be applied to the total value to convert into appropriate engineering units. As a rate total, the default is Units/Day. If the actual units of the continuous measurement are Units/Minute, you would multiply the results by 1440 (minutes per day) to convert the total into appropriate engineering units. |
3 |
Minimum | Retrieves the minimum value for each calculation interval. | 4 |
Maximum | Retrieves the maximum value for each calculation interval. | 5 |
Count | Counts the number of raw samples found with good quality in the interval. Value is the count of raw samples with good quality in the interval. The values of each sample are ignored. The Count does not include any samples of bad quality, including the start and end of collection markers. For Quality, the percentage of good samples is always 100, even if the interval does not contain any raw samples, or contains only bad quality samples. Count is useful for analyzing the distribution of the raw data samples to determine the effect of compression deadbands. It is also useful to determine which tags are consuming the most archive space. |
6 |
RawAverage | Retrieves the arithmetic average of all good quality raw samples for each calculation interval. Value is the sum of all good quality samples in the interval, divided by the number of good quality samples in the interval. All bad quality samples are ignored. That is RawAverage is equivalent to RawTotal divided by the Count. For Quality, if there are no raw samples in the interval or if they all are bad quality, then the percentage of good is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad quality samples. RawAverage is useful for calculating an accurate average when a sufficient number of raw samples are collected. |
7 |
RawStandardDeviation | Retrieves the arithmetic standard deviation of raw values for each calculation interval. For Value, any raw point of bad data quality is ignored. For Quality, if there are no raw samples in the interval or they all have bad quality, then the percentage of good is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad quality samples. RawStandardDeviation is useful for calculating an accurate standard deviation when a sufficient number of raw samples are collected. |
8 |
RawTotal | Retrieves the arithmetic total (sum) of sampled values for each interval. Value is the sum of the good quality values of all raw samples in the interval. All bad quality samples are ignored. For Quality, the percentage of good samples is always 100, even if the interval does not contain any raw samples or it contains only bad quality samples. If the same start and end times are used, and the time span is treated as a single interval, then all values are added together. RawTotal is useful for calculating an accurate total when a sufficient number of raw samples are collected. Note that unlike ihTotal, this is a simple sum with no assumption that the values are rate values. |
9 |
MinimumTime | Retrieves the timestamp of the minimum value found within each calculation interval. It can be a raw or an interpolated value. The minimum must be a good data quality sample. | 10 |
MaximumTime | Retrieves the timestamp of the maximum value found within each calculation interval. It can be a raw or an interpolated value. The maximum must be a good data quality sample. | 11 |
TimeGood | Retrieves the amount of time (milliseconds) during the interval when the data is of good quality and the filter condition is met. | 12 |
StateCount | Retrieves the amount of time a tag uses to transition to another state from a previous state during a time interval. | 13 |
StateTime | Retrieves the duration that a tag stayed in a given state within an interval. | 14 |
OPCQAnd | Retrieves the OPCQAND, bit-wise AND operation of all the 16-bit OPC qualities of the raw samples stored in the specified interval. Note that OPC Quality is a subfield for Quality-Value-Timestamp (QVT), so when this calculation mode is used, OPC Quality is considered for calculation. |
15 |
OPCQOr | Retrieves the OPCQOR, bit-wise OR operation of all the 16-bit OPC qualities of the raw samples stored in the specified interval. Note that OPC Quality is a subfield for Quality-Value-Timestamp (QVT), so when this calculation mode is used, OPC Quality is considered for calculation. |
16 |
FirstRawValue | Retrieves the first good raw sample value for a given interval. Value is the value of the raw sample, or zero if there are no good raw samples in the interval. For Quality, if there are not good raw samples in the interval, then the percentage of good is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad quality samples. Note that Quality is the same for FirstRawValue and FirstRawTime. The Raw sample has a quality of Good, Bad, or Uncertain, and that is converted to a 0 or 100 percent. |
17 |
FirstRawTime | Retrieves the first good raw timestamp for a given interval. Value is the timestamp of the sample or the year 1969 if there are no good raw samples in the interval. For Quality, if there are not good raw samples in the interval, then the percentage of good is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad quality samples. Note that Quality is the same for FirstRawValue and FirstRawTime. The Raw sample has a quality of Good, Bad, or Uncertain, and that is converted to a 0 or 100 percent. |
18 |
LastRawValue | Retrieves the last good raw sample value for a given time interval. Value is the value of the raw sample or zero if there are no good raw samples in the interval. For Quality, if there are no good raw samples in the interval, the the percentage of good samples is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad samples. Note that Quality is the same for LastRawValue and LastRawTime. The Raw sample has a quality of Good, Bad, or Uncertain, and that is converted to a 0 or 100 percent. |
19 |
LastRawTime | Retrieves the last good timestamp of the last value for a given time interval. Value is the timestamp of the sample or the year 1969 if there are no good raw samples in the interval. For Quality, if there are no good raw samples in the interval, the percentage of good samples is 0. Otherwise, the percentage of good is always 100, even if the interval contains bad samples. Note that Quality is the same for LastRawValue and LastRawTime. The Raw sample has a quality of Good, Bad, or Uncertain, and that is converted to a 0 or 100 percent. |
20 |
TagStats | Retrieves the statistics for a tag from the archive stored in the specified interval. | 21 |
FilterModeType Parameter
The FilterModeType parameter defines how time periods before and after transitions in the filter condition should be handled.
When the FilterModeType parameter is applied, then the Start time and End time are specified as:
- ExactTime
- BeforeTime
- AfterTime
- BeforeAndAfterTime
For example, AfterTime indicates that the filter condition should be True starting at the timestamp of the archive value that triggered the True condition, and leading up to the timestamp of the archive value that triggered the False condition.
Properties | Description | Value |
---|---|---|
ExactTime | Retrieves data for the exact times that the filter condition is True. | 1 |
BeforeTime | Retrieves data from the timestamp of the last False filter condition to the timestamp of the next True condition. | 2 |
AfterTime | Retrieves data from the timestamp of the True filter condition to the timestamp of the next False condition. | 3 |
BeforeAndAfterTime | Retrieves data from the timestamp of the last False filter condition to the timestamp of the next False condition. | 4 |
ReturnDataFields Parameter
Each time-series data sample contains QVT (quality, value, and timestamp) values. If ReturnDataFields is not provided, then the default value of 0 is considered, and all QVT values are returned for each data sample. To return one of the data field properties, such as TimeStamp, use the TimeStamp option as shown in the table.
Properties | Description | Field value (Boolean) |
---|---|---|
All Fields | Specifies that all data fields are returned in the query. | 0 (0000) |
TimeStamp | The time stamp of the collected sample or an interval time stamp. When specified in the query, returns the TimeStamp property. | 1 (0001) |
Value | The collected value or sampled value; the data type of the value will be the same data type as the tag's raw data. | 2 (0010) |
Quality | When specified in the query, returns the Quality property. Each sample in Current Value and Raw query retrieval has a quality of:
Interpolated and Lab Retrieval express quality as "percent good". |
4 (0100) |
Payload Parameter
This parameter queries for the tag properties requested from the server.
The properties listed in the following table are valid in APIs that use the Payload parameter, unless otherwise specified. For Property Names used in the Get Tag Properties API, the property name is always a Boolean (true/false) value, while it can be a string or integer for other APIs.
Property Name | Property Type | Description |
---|---|---|
AllFields | Boolean | Used for Get Tag Properties API. |
Name | Boolean, String | Used for the Get Tag Properties API, Add Single Tag API, and Add Bulk Tags API. |
Description | String | |
EngineeringUnits | String | |
Comment | String | |
DataType : ihDataType | SignedIntegral | Type definition is an enumerated type "ihDataType".
|
FixedStringLength | UnsignedChar | |
CollectorName | String | |
SourceAddress | String | |
CollectionType : ihCollectionType | SignedIntegral | Type definition is an enumerated type "ihCollectionType".
|
CollectionInterval | SignedIntegral | |
CollectionOffset | UnsignedLong | |
LoadBalancing | Boolean | |
TimeStampType : ihTimeStampType | SignedIntegral | Type definition is an enumerated type "ihTimeStampType".
|
HiEngineeringUnits | Double | |
LoEngineeringUnits | Double | |
InputScaling | Boolean | |
HiScale | Double | |
LoScale | Double | |
CollectorCompression | Boolean | |
CollectorDeadbandPercentRange | Float | |
ArchiveCompression | Boolean | |
ArchiveDeadbandPercentRange | Float | |
General1 | String | |
General2 | String | |
General3 | String | |
General4 | String | |
General5 | String | |
ReadSecurityGroup | String | |
WriteSecurityGroup | String | |
AdministratorSecurityGroup | String | |
LastModified | Boolean | Used for Get Tag Properties API. |
LastModifiedUser | Boolean | Used for Get Tag Properties API. |
InterfaceType | Boolean | Used for Get Tag Properties API. |
CollectorType : ihInterfaceType | SignedIntegral | Type definition is an enumerated type "ihInterfaceType".
|
UTCBias | SignedIntegral | |
AverageCollectionTime | Boolean | Used for Get Tag Properties API. |
CalculationDependencies | StringArray | |
CollectionDisabled | Boolean | |
ArchiveCompressionTimeout | UnsignedLong | |
CollectorCompressionTimeout | UnsignedLong | |
SpikeLogic | Boolean | |
SpikeLogicOverride | Boolean | |
CollectorAbsoluteDeadbanding | Boolean | |
CollectorAbsoluteDeadband | Double | |
ArchiveAbsoluteDeadbanding | Boolean | |
ArchiveAbsoluteDeadband | Double | |
StepValue | Boolean | |
TimeResolution : ihTimeResolution | SignedIntegral | Type definition is an enumerated type "ihTimeResolution".
|
ConditionCollectionEnabled | Boolean | |
ConditionCollectionTriggerTag | String | |
ConditionCollectionComparison : ihConditionCollectionComparison | SignedIntegral | Type definition is an enumerated type "ihConditionCollectionComparison".
|
ConditionCollectionCompareValue | String | |
ConditionCollectionMarkers | Boolean | |
Calculation | String | When the Calculation field is used, then two more conditions are required. Calculation is not a specific field for a tag property. If the tag's collector or interface type is Server-to-server and the Calculation field is set (not Null), then the field value is set to the source address. |
TagId | Boolean | Used for Get Tag Properties API. |
EnumeratedSetName | String | |
DataStoreName | String | |
DefaultQueryModifiers | Long Long | |
UserDefinedTypeName | String | |
NumberOfElements | SignedIntegral | |
DataDensity : ihTagDataDensity | SignedIntegral | Type definition is an enumerated type "ihTagDataDensity".
|
CalcType : ihTagCalcType | SignedIntegral | Type definition is an enumerated type "ihCalcType".
|
HasAlias | Boolean | Used for Get Tag Properties API. |
IsStale | Boolean | Used for Get Tag Properties API. |
Error Code Definitions
Error Code Value: | Error Code Definition |
---|---|
Success = 0 | Operation successful. |
Failed = -1 | Operation failed. |
Timeout = -2 | Operation failed due to timeout. |
NotConnected = -3 | Not connected to Historian server. |
CollectorNotFound = -4 | The given collector does not exist on the server. |
NotSupported = -5 | Operation not supported. |
DuplicateData = -6 | Attempt to overwrite an existing data sample. |
InvalidUsername = -7 | Bad user name or password. |
AccessDenied = -8 | Insufficient permissions for operation. |
WriteInFuture = -9 | Attempted data write too far in the future. |
WriteArchiveOffline = -10 | Attempted data write to an offline archive. |
WriteArchiveReadonly = -11 | Attempted data write to a read-only archive. |
WriteOutsideActiveRange = -12 | Attempted data write beyond the configured active range. |
WriteNoArchiveAvailable = -13 | Attempted data write with no available archives. |
InvalidTagname = -14 | The requested tag was not found. |
LicensedTagCountExceeded = -15 | Number of licensed tags exceeded. |
LicensedConnectionCountExceeded = -16 | Number of licensed server connections exceeded. |
InternalLicenseError = -17 | Internal license error. |
NoValue = -18 | No available tag data. |
DuplicateCollector = -19 | The given collector name already exists on the server. |
NotLicensed = -20 | Server or feature is not licensed. |
CircularReference = -21 | Circular reference detected in calculation. |
BackupInsufficientSpace = -22 | Insufficient disk space to perform backup. |
InvalidServerVersion = -23 | Operation unsupported due to server version. |
QueryResultSizeExceeded = -24 | Upper limit on query results exceeded. |
DeleteOutsideActiveRange = -25 | Attempted data delete outside allowed modification interval. |
AlarmArchiverUnavailable = -26 | Alarm and Event subsystem unreachable. |
ArgumentException = -27 | A supplied argument is invalid. |
ArgumentNullException = -28 | A supplied argument is NULL. |
ArgumentOutOfRangeException = -29 | A supplied argument is outside the valid range. |
InvalidEnumeratedSet = -30 | The requested Enumerated Set was not found. |
InvalidDataStore = -31 | The requested data store was not found. |
NotPermitted = -32 | Operation not permitted. |
InvalidCustomDataType = -33 | The Custom data type is not supported. |
ihSTATUS_EXISTING_USERDEF_REFERENCES = -34 | N/A |
ihSTATUS_INVALID_TAGNAME_DELETEDTAG = -35 | N/A |
ihSTATUS_INVALID_DHS_NODENAME = -36 | N/A |
ihSTATUS_DHS_SERVICE_IN_USE = -37 | N/A |
ihSTATUS_DHS_STORAGE_IN_USE = -38 | N/A |
ihSTATUS_DHS_TOO_MANY_NODES_IN_MIRROR = -39 | N/A |
ihSTATUS_ARCHIVE_IN_SYNC = -40 | N/A |
InvalidArchiveName= -41 | N/A |
InvalidSession = 1 | Session id is invalid. |
SessionExpired = 2 | Session has expired. |
UnknownError = 3 | Unknown error, please check server log. |
NoValidClientBufferManager= 4 | No valid client buffer manager. |
NoValueInDataSet = 5 | No value in returned data set. |
TagNotExisting = 6 | Tag doesn't exist. |
ClientBufferManagerCommunicationError = 7 | Service call to central buffer server fail. |
TagTypeNotSupported=8 | Tag type is not supported. |
ValueTypeNotMatchTagDataType = 9 | Value type doesn't match tag data type. |
InvalidParameter=10 | Invalid query parameter. |
TagSearchResultIsHuge = 11 | Tag Search Criteria result was more than 5000. |
InvalidHistorianServer=12 | No valid server or historian server name isn't in the server list. |