-
Notifications
You must be signed in to change notification settings - Fork 74
Example queries
All these examples are not urlencoded, for readability. If you use these examples, don't forget to urlencode.
All things with an Id greater equal 5 and lessequal 20:
v1.0/Things?$filter=id ge 15 and id le 20
The phenomenonTime and result of the first 1000 observations, ordered by phenomenonTime that overlap with the time frame from 2017-10-10 07:00:00 UTC to 2017-10-11 07:00:00 UTC (1 day):
v1.0/Observations
?$orderby=phenomenonTime asc
&$top=1000
&$select=phenomenonTime, result
&$filter=overlaps(phenomenonTime, 2017-10-10T07:00:00Z/2017-10-11T07:00:00Z)
The observations of a Datastream, for the last day:
Datastreams(1)/Observations?$filter=phenomenonTime gt now() sub duration'P1D'
The observations of a Datastream, for the last days, where the number of days is configured in properties/days of the Datastream:
Datastreams(1)/Observations?$filter=phenomenonTime gt now() sub duration'P1D' mul Datastream/properties/days
All observations with an even result
Observations?$filter=result mod 2 eq 0
Datastreams that have data for the ObservedProperty with id 1
Datastreams?$filter=ObservedProperty/@iot.id eq 1
ObservedProperties that are measured at the same station as the ObservedProperty with name Temperature
ObservedProperties?$filter=Datastream/Thing/Datastreams/ObservedProperty/name eq 'Temperature'
Filtering Observations where result is greater than a threshold stored in the properties of their Thing. The "add 0" is to indicate we want to use a numeric comparison. Since both Observation/result and Thing/properties can be anything, the server would otherwise default to a (safe) string-comparison.
Observations?$filter=result gt Datastream/Things/properties/max add 0
Functions work for Ordering
Datastreams?$orderby=length(name) desc
All things, with their current Locations and Datastreams, and for those Datastreams the ObservedProperty and the last Observation:
v1.0/Things
?$select=name,description,@iot.id
&$expand=
Locations
($select=name,description,location,@iot.id)
,Datastreams
($select=name,description,@iot.id
;$expand=
Sensor
($select=name,description,@iot.id)
,ObservedProperty
($select=name,description,@iot.id)
,Observations
($select=result,phenomenonTime,@iot.id
;$orderby=phenomenonTime%20desc
;$top=2
)
)