Common API Parameters

TagNames Parameter

By default, the Historian REST service provides support to read samples for multiple tags. Multiple tag names are separated by semicolons (;). For example, "tagname1;tagname2;tagname3".
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 NameDescription
StartTimeStart 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.

EndTimeEnd 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

The TagSamples parameter is the output from the REST API calls.
Property NameProperty TypeDescription
TagNameStringName of the tag.
DataTypeStringTag Data Type Value:
  • Blob Stores tags as binary large objects. The Blob datatype generally refers to undetermined binary data types, such as an Excel spreadsheet, a PDF file, or a Word file.
  • Boolean (one byte) Stores boolean values. Valid values for the boolean data type are 0=FALSE and 1=TRUE. If the user sends zero, the value is taken as zero. Anything other than zero, the value is treated as one.
  • Byte (one byte) Stores integer values. Valid values for the byte data type are -128 to +127.
  • SingleFloat (four bytes) Stores decimal values up to six places. Valid ranges for the single float data type are 1.175494351e-38F to 3.402823466e+38F
  • DoubleFloat (eight bytes) Stores decimal values up to 15 places. Valid values for the double float data type are 2.2250738585072014e-308 to 1.7976931348623158e+308.
  • SingleInteger (two bytes) Stores whole numbers, without decimal places. Valid values for the single integer data type are -32767 to +32767.
  • DoubleInteger (four bytes) Stores whole numbers, without decimal places. Valid values for the double integer data type are -2147483648 to +2147483648.
  • FixedString (Configured by user) Stores string data of a fixed size. Valid values are between 0 and 255 bytes.
  • Float Single float.
  • Integer Single integer.
  • MultiField Stores string data that has multiple words.
  • QuadInteger (eight bytes) Stores whole numbers without decimal places. Valid values for the quad integer data type are -9,223,372,036,854,775,808 (negative nine quintillion) to +9,223,372,036,854,775,807 (positive nine quintillion).
  • Scaled (two bytes) Lets you store a four-byte float as a twobyte integer in the Historian archive. The scaled data type saves disk space but sacrifices data precision as a result.
  • Time Returns or sets the type of time stamping applied to data at collection time.
  • UDoubleInteger (Unsigned Double Integer) (four bytes) Stores whole numbers without decimal places. Valid values for the unsigned double integer data type are 0 to 4,294,967, 295 (4.2 billion).
  • Undefined Data type is not defined.
  • UQuadInteger (Unsigned Quad Integer) (eight bytes) Stores whole numbers without decimal places. Valid values for the unsigned quad integer data type are 0 to 18,446,744,073,709,551,615 (19 quintillion).
  • USingleInteger (Unsigned Single Integer) (two bytes) Stores whole numbers without decimal places. Valid values for the unsigned single integer data type are 0 to 65535.
  • VariableString (No fixed size) Stores string values of undetermined size. This data type is useful if you cannot rely on a constant string length from your data source.
  • Array Returns an array of tags from your data source. You can specify orientation, size, and number of rows returned in the array.
ErrorCodeError CodeError Code Definition

See Error Code Definition for more information.

SamplesData SampleSee DataSample Parameter for more information.

DataSample Parameter

The DataSample Parameter specifies the number of data samples to retrieve from the archive. Samples are evenly spaced within the time range defined by start time and end time for most sampling modes.
Property NameProperty TypeDescription
ValueStringFormat 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.

TimeStampDateTimeStart 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.
QualityInteger

(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".
Value and Status
  • 0 Bad
  • 1 Uncertain
  • 2 NA
  • 3 Good

SamplingModeType Parameter

The SamplingModeType parameter is the mode of sampling data from the archive. The default setting for the Sampling Mode is Calculated.
PropertiesDescriptionValue
UndefinedSampling mode is not defined.0
CurrentValueRetrieves the current value. The time- interval criteria are ignored.1
InterpolatedRetrieves evenly-spaced, interpolated values based on interval or NumberOfSamples and the time-frame criteria.2
TrendReturns 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
RawByTimeRetrieves raw archive values based on time-frame criteria.4
RawByNumberRetrieves raw archive values based on the StartTime criteria, the NumberOfSamples, and Direction criteria. The EndTime criteria is ignored for this sampling mode.5
CalculatedRetrieves evenly spaced calculated values based on NumberOfSamples, interval, the time frame criteria, and the CalculationMode criteria.6
LabReturns actual collected values without interpolation.7
InterpolatedtoRawProvides raw data in place of interpolated data when the number of samples are fewer than the available samples.8
TrendtoRawThe 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
LabtoRawProvides raw data for the selected calculated data, when NumberOfSamples is less than the available samples.10
RawByFilterToggleReturns filtered time ranges using the following values:
  • 1 true
  • 0 false

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

The Direction Parameter specifies the direction (Forward or Backward from the starting time) of data sampling from the archive. The default value is Forward.
DirectionValue
Forward0
Backward1

CalculationModeType Parameter

The CalculationModeType parameter is only applied if the Sampling Mode is set to Calculated. It represents the type of calculation to use on the archive data. The default Calculation Mode, if none is specified, is Average.
Calculation Mode TypeDescriptionValue
UndefinedCalculation mode is not defined.0
AverageRetrieves the time-weighted average for each calculation interval.1
StandardDeviationRetrieves the time-weighted standard deviation for each calculation interval.2
TotalRetrieves 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
MinimumRetrieves the minimum value for each calculation interval.4
MaximumRetrieves the maximum value for each calculation interval.5
CountCounts 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
RawAverageRetrieves 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
RawStandardDeviationRetrieves 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
RawTotalRetrieves 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
MinimumTimeRetrieves 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
MaximumTimeRetrieves 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
TimeGoodRetrieves the amount of time (milliseconds) during the interval when the data is of good quality and the filter condition is met.12
StateCountRetrieves the amount of time a tag uses to transition to another state from a previous state during a time interval.13
StateTimeRetrieves the duration that a tag stayed in a given state within an interval.14
OPCQAndRetrieves 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
OPCQOrRetrieves 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
FirstRawValueRetrieves 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
FirstRawTimeRetrieves 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
LastRawValueRetrieves 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 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
LastRawTimeRetrieves 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
TagStatsRetrieves 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.

PropertiesDescriptionValue
ExactTimeRetrieves data for the exact times that the filter condition is True.1
BeforeTimeRetrieves data from the timestamp of the last False filter condition to the timestamp of the next True condition.2
AfterTimeRetrieves data from the timestamp of the True filter condition to the timestamp of the next False condition.3
BeforeAndAfterTimeRetrieves data from the timestamp of the last False filter condition to the timestamp of the next False condition. 4

ReturnDataFields Parameter

The ReturnDataFields bitwise parameter specifies which data fields are returned in a query. Using it in a query returns data such as TimeStamp, and each field returns a Boolean value.

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.

PropertiesDescriptionField value (Boolean)
All FieldsSpecifies that all data fields are returned in the query.0 (0000)
TimeStampThe time stamp of the collected sample or an interval time stamp. When specified in the query, returns the TimeStamp property. 1 (0001)
ValueThe 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)
QualityWhen specified in the query, returns the Quality property. Each sample in Current Value and Raw query retrieval has a quality of:
  • Good (3)
  • Not Available (2)
  • Uncertain (1)
  • Bad (0)

Interpolated and Lab Retrieval express quality as "percent good".

4 (0100)

Payload Parameter

This parameter queries for the tag properties requested from the server.

Use the Payload parameter to query for all the tag properties to return from the server. In the Update Tag Configuration API, you must provide the actual tag property value. However, in the Get Tag Properties API, you must provide the property name and value of 1 (true), so the property can be read from the server and returned.

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 NameProperty TypeDescription
AllFieldsBooleanUsed for Get Tag Properties API.
NameBoolean, StringUsed for the Get Tag Properties API, Add Single Tag API, and Add Bulk Tags API.
DescriptionString
EngineeringUnitsString
CommentString
DataType : ihDataTypeSignedIntegralType definition is an enumerated type "ihDataType".
{
ihDataTypeUndefined = 0,
ihScaled,
ihFloat,
ihDoubleFloat,
ihInteger,
ihDoubleInteger,
ihFixedString,
ihVariableString,
ihBlob,
ihTime,
ihInt64,
ihUInt64,
ihUInt32,
ihUInt16,
ihByte,
ihBool,
ihMultiField,
ihArray,
ihMaxDataType
} ihDataType;
FixedStringLengthUnsignedChar
CollectorNameString
SourceAddressString
CollectionType : ihCollectionTypeSignedIntegralType definition is an enumerated type "ihCollectionType".
{
ihUnsolicited = 1,
ihPolled
} ihCollectionType;
CollectionIntervalSignedIntegral
CollectionOffsetUnsignedLong
LoadBalancingBoolean
TimeStampType : ihTimeStampTypeSignedIntegralType definition is an enumerated type "ihTimeStampType".
{
ihSource = 1,
ihInterface,
} ihTimeStampType;
HiEngineeringUnitsDouble
LoEngineeringUnitsDouble
InputScalingBoolean
HiScaleDouble
LoScaleDouble
CollectorCompressionBoolean
CollectorDeadbandPercentRangeFloat
ArchiveCompressionBoolean
ArchiveDeadbandPercentRangeFloat
General1String
General2String
General3String
General4String
General5String
ReadSecurityGroupString
WriteSecurityGroupString
AdministratorSecurityGroupString
LastModifiedBooleanUsed for Get Tag Properties API.
LastModifiedUserBooleanUsed for Get Tag Properties API.
InterfaceTypeBooleanUsed for Get Tag Properties API.
CollectorType : ihInterfaceTypeSignedIntegralType definition is an enumerated type "ihInterfaceType".
{
ihInterfaceUndefined = 0,
ihIFix,
ihRandom,
ihOPC,
ihFile,
ihIFixLabData,
ihManualEntry,
ihOther,
ihCalcEngine,
ihServerToServer,
ihPI,
ihOPCAE,
ihCIMPE,
ihPIDistributor,
ihCIMME,
ihPerfTag,
ihCustom,
ihServerToServerDistributor,
ihWindowsPerfMon,
} ihInterfaceType;
UTCBiasSignedIntegral
AverageCollectionTimeBooleanUsed for Get Tag Properties API.
CalculationDependenciesStringArray
CollectionDisabledBoolean
ArchiveCompressionTimeoutUnsignedLong
CollectorCompressionTimeoutUnsignedLong
SpikeLogicBoolean
SpikeLogicOverrideBoolean
CollectorAbsoluteDeadbandingBoolean
CollectorAbsoluteDeadbandDouble
ArchiveAbsoluteDeadbandingBoolean
ArchiveAbsoluteDeadbandDouble
StepValueBoolean
TimeResolution : ihTimeResolutionSignedIntegralType definition is an enumerated type "ihTimeResolution".
{
ihSeconds = 0,
ihMilliseconds,
ihMicroseconds,
ihNanoseconds
} ihTimeResolution;
ConditionCollectionEnabledBoolean
ConditionCollectionTriggerTagString
ConditionCollectionComparison : ihConditionCollectionComparisonSignedIntegralType definition is an enumerated type "ihConditionCollectionComparison".
{
ihConditionComparisonUndefined = 0,
ihConditionComparisonEqual,
ihConditionComparisonLessThan,
ihConditionComparisonLessThanEqual,
ihConditionComparisonGreaterThan,
ihConditionComparisonGreaterThanEqual,
ihConditionComparisonNotEqual
} ihConditionCollectionComparison;
ConditionCollectionCompareValueString
ConditionCollectionMarkersBoolean
CalculationStringWhen 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.
TagIdBooleanUsed for Get Tag Properties API.
EnumeratedSetNameString
DataStoreNameString
DefaultQueryModifiersLong Long
UserDefinedTypeNameString
NumberOfElementsSignedIntegral
DataDensity : ihTagDataDensitySignedIntegralType definition is an enumerated type "ihTagDataDensity".
{
ihDataDensityUndefined = 0,
ihDataDensityMinimum = 1,
ihDataDensityMedium = 4,
ihDataDensityMaximum = 7
} ihTagDataDensity;
CalcType : ihTagCalcTypeSignedIntegralType definition is an enumerated type "ihCalcType".
{
ihRawTag = 0,
ihAnalyticTag = 1,
ihPythonExprTag = 2
} ihTagCalcType;
HasAliasBooleanUsed for Get Tag Properties API.
IsStaleBooleanUsed for Get Tag Properties API.

Error Code Definitions

The following table provides the values and definitions for the ErrorCode parameter.
Table 1. Error Code Definitions
Error Code Value:Error Code Definition
Success = 0Operation successful.
Failed = -1Operation failed.
Timeout = -2Operation failed due to timeout.
NotConnected = -3Not connected to Historian server.
CollectorNotFound = -4The given collector does not exist on the server.
NotSupported = -5Operation not supported.
DuplicateData = -6Attempt to overwrite an existing data sample.
InvalidUsername = -7Bad user name or password.
AccessDenied = -8Insufficient permissions for operation.
WriteInFuture = -9Attempted data write too far in the future.
WriteArchiveOffline = -10Attempted data write to an offline archive.
WriteArchiveReadonly = -11Attempted data write to a read-only archive.
WriteOutsideActiveRange = -12Attempted data write beyond the configured active range.
WriteNoArchiveAvailable = -13Attempted data write with no available archives.
InvalidTagname = -14The requested tag was not found.
LicensedTagCountExceeded = -15Number of licensed tags exceeded.
LicensedConnectionCountExceeded = -16Number of licensed server connections exceeded.
InternalLicenseError = -17Internal license error.
NoValue = -18No available tag data.
DuplicateCollector = -19The given collector name already exists on the server.
NotLicensed = -20Server or feature is not licensed.
CircularReference = -21Circular reference detected in calculation.
BackupInsufficientSpace = -22Insufficient disk space to perform backup.
InvalidServerVersion = -23Operation unsupported due to server version.
QueryResultSizeExceeded = -24Upper limit on query results exceeded.
DeleteOutsideActiveRange = -25Attempted data delete outside allowed modification interval.
AlarmArchiverUnavailable = -26Alarms and Events subsystem unreachable.
ArgumentException = -27A supplied argument is invalid.
ArgumentNullException = -28A supplied argument is NULL.
ArgumentOutOfRangeException = -29A supplied argument is outside the valid range.
InvalidEnumeratedSet = -30The requested Enumerated Set was not found.
InvalidDataStore = -31The requested data store was not found.
NotPermitted = -32Operation not permitted.
InvalidCustomDataType = -33The Custom data type is not supported.
ihSTATUS_EXISTING_USERDEF_REFERENCES = -34N/A
ihSTATUS_INVALID_TAGNAME_DELETEDTAG = -35N/A
ihSTATUS_INVALID_DHS_NODENAME = -36N/A
ihSTATUS_DHS_SERVICE_IN_USE = -37N/A
ihSTATUS_DHS_STORAGE_IN_USE = -38N/A
ihSTATUS_DHS_TOO_MANY_NODES_IN_MIRROR = -39N/A
ihSTATUS_ARCHIVE_IN_SYNC = -40N/A
InvalidArchiveName= -41N/A
InvalidSession = 1Session id is invalid.
SessionExpired = 2Session has expired.
UnknownError = 3Unknown error, please check server log.
NoValidClientBufferManager= 4No valid client buffer manager.
NoValueInDataSet = 5No value in returned data set.
TagNotExisting = 6Tag doesn't exist.
ClientBufferManagerCommunicationError = 7Service call to central buffer server fail.
TagTypeNotSupported=8Tag type is not supported.
ValueTypeNotMatchTagDataType = 9Value type doesn't match tag data type.
InvalidParameter=10Invalid query parameter.
TagSearchResultIsHuge = 11Tag Search Criteria result was more than 5000.
InvalidHistorianServer=12No valid server or historian server name isn't in the server list.
ihSTATUS_INVALID_INTERFACETYPE = -49 The collector type is not valid. For a list of collector types, refer to Collector Type and Subtype.
ihSTATUS_INTERFACE_START_FAIL = -50 Starting the collector has failed.
ihSTATUS_INTERFACE_STOP_FAIL = -51 Stopping the collector has failed.