QueryStreamEntriesWithData
Description
You can use this service to query for stream entries based on the specified input parameters. The result will contain the entry ID, location, source, source type, data tags, time stamp, and the fields defined in the Data Shape associated with the stream.
Inputs
Parameter Name
Description
Base Type
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 the stream entry was created.
DATETIME
endDate
The timestamp before 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, timestamp, and the fields defined in the Data Shape associated with the stream.
INFOTABLE
Example
In the following example, TestStream has a Data Shape that has Property1, Property2, and Property3.
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, data tags of the stream entry, timestamp, Property1, Property2, and Property3:
result = Things["TestStream"].QueryStreamEntriesWithData({
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?