QueryStreamEntries
Description
You can use this service to query the stream entries based on the specified input parameters. The query and filter is similar to QueryStreamEntriesWithData; however, the resulting infotable contains only the Entry ID, location, source, source type, data tags and timestamp.
Input
Parameter name
Description
BaseType
maxItems
Maximum number of items to return in the result set. The default value is 500. This parameter is applied after all other filters are applied.
NUMBER
source
Source for the stream entry. When the stream entry was created, a valid source_type should have been selected. This source can have model tags.
STRING
tags
Data tags associated with the stream entry.
TAGS
sourceTags
Model tags associated with the source of this entry.
TAGS
startDate
The timestamp after which the stream entry was created.
DATETIME
endDate
The timestamp before which the stream entry was created.
DATETIME
oldestFirst
Retrieve from the oldest or the newest records. By default, this value is false.
BOOLEAN
query
The query criteria to filter data.
For more information, see Query Parameter for Query Services
QUERY
Output
Parameter Name
Description
Base Type
result
Returns an infotable that contains the entry ID, location, source, source type, data tags, and time stamp.
INFOTABLE
Example
In the following example, TestStream has a Data Shape that has fields, Property1, Property2, and Property3 fields.
Entity
ModelTags
Administrator
System
Thing1
{vocabulary: "MT1", vocabularyTerm: "MT1-MTerm1"}
entry_id
source
source_type
location
DataTags
Property1
Property2
Property3
1
System
User
1
2
3
2
Administrator
User
a
b
c
3
Thing1
Thing
{vocabulary: "DataTag1", vocabularyTerm: "DT1-Term1"}
1
2
3
4
AAA
Unknown
aa
bb
cc
5
Thing1
Thing
{vocabulary: "DataTag1", vocabularyTerm: "DT1-Term1"}
1
2
3
The following example shows a query for stream entries using all supported parameters. This API call returns an infotable that contains the entry ID, location, source, source type, and data tags of the stream entry and, timestamp:
result = Things["TestStream"].QueryStreamEntries({
maxItems: 50,
source: 'Thing1',
tags: "DataTag1:DT1-Term1", /* Data tags on Stream Entry */
sourceTags: "MT1:MT1-MTerm1", /* Model tags on Source entity */
startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
endDate: Date.now(),
oldestFirst: false,
query: "{ \"sorts\": [{\"fieldName\": \"Property1\"}]}"
});
Was this helpful?