Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Sensor thingsapi webinar-#3-rest-for-iot-api-20151210

933 views

Published on

OGC SensorThings API Get Started Webinar Series #3 of 4. (Dec 10 2015)

Title: RESTful Pattern for IoT API


More to come:
#4: Connect Sensors and IoT Devices to SensorThings API (Dec 17th 2015)

Register our webinar here: http://sensorup.com/#signup

Published in: Internet
  • Hi there! Get Your Professional Job-Winning Resume Here - Check our website! http://bit.ly/resumpro
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Sensor thingsapi webinar-#3-rest-for-iot-api-20151210

  1. 1. OGC SensorThings API Tutorial #3 - RESTful Pattern for IoT API 0.23 litre/minute 0.25 litre/minute 0.27 litre/minuteRH: 85 % Temp: 18 Celsius Dr. Steve Liang Chair, OGC SensorThings API Standard Working Group Founder and CEO, SensorUp Inc. Associate Professor, University of Calgary
  2. 2. sensorup.com@sensorup Agenda • Recap: OGC SensorThings Data Model • IoT API RESTful Pattern • Many Examples
  3. 3. sensorup.com@sensorup About Dr. Steve Liang • Associate Professor, Geomatics Engineering, Uni. Calgary • AITF-Microsoft Industry Chair on Open Sensor Web • Chair OGC SensorThings API Standard Working Group • Co-Chair OGC Sensor Web Enablement Domain Working Group • N.A. Chair, OGC University Domain Working Group • Rapporteur, ITU-T SG12/11 on Internet of Things Test Specifications • Founder and CEO, SensorUp Inc, a University of Calgary startup (http://www.sensorup.com)
  4. 4. sensorup.com@sensorup About SensorUp • We are a world leader in OGC Sensor Web and IoT • We are leading several international IoT standard development efforts (OGC and ITU-T) • We developed world’s first OGC SensorThings API implementation
  5. 5. 5 Data Model
  6. 6. Prerequisites • Basic knowledge of REST (REpresentational State Transfer) • https://en.wikipedia.org/wiki/Representational_state_transfer • Basic knowledge of JSON (JavaScript Object Notation) • http://www.json.org/
  7. 7. Before We Start • It’s all about LINKS! • great discoverability • great for dynamic use cases • efficient and great developer experiences • big data analytics friendly • Uniform and Consistent Pattern
  8. 8. SensorThings Entities Common Control Information 8 Annotation Definition Data type Multiplicity @iot.id system generated identifier Any 1 @iot.selfLink absolute URL of an entity URL 1 @iot.navigationLink link leading to related entities URL 1…*
  9. 9. Common Control Information 9
  10. 10. IoT API URL Patterns based on SensorThings 10
  11. 11. URI version 11
  12. 12. #1 Root URL 12
  13. 13. #2 Address to an entity set 13 one of the eight entities, e.g., Things, Datastreams
  14. 14. #3 Address to an individual entity 14
  15. 15. #4 Address to a property of an entity 15
  16. 16. #5 Address to the value of a property of an entity 16
  17. 17. #6 Address to a navigation property (navigationLink) 17
  18. 18. #7 Address to an association link 18
  19. 19. #8 Nested Resource Path 19
  20. 20. Query Options 20
  21. 21. Evaluating System Query Options 21 • Prior to applying any server-driven paging: • $filter • $orderby • $skip • $top • After applying any server-driven paging: • $expand • $select
  22. 22. The $expand system query option indicates the related entities to be represented inline. Über flexibility! Example 1: http://example.org/v1.0/Things?$expand=Datastreams returns the entity set of Things as well as each of the Datastreams associated with each Thing entity $expand
  23. 23. E x a m p l e 2 : http://example.org/v1.0/Things? $expand=Datastreams/ObservedProperty returns the collection of Things, the Datastreams associated with each Thing, and the ObservedProperty associated with each Datastream. Example 3: http://example.org/v1.0/Datastreams(1)? $expand=Observations,ObservedProperty returns the Datastream whose id is 1 as well as the Observations and ObservedProperty associated with this Datastream.
  24. 24. The $select system query option requests that the service to return only the properties explicitly requested by the client. E x a m p l e 1 : http://example.org/v1.0/Observations? $select=result,resultTime $select Great for performance! Reduce response time and data size.
  25. 25. E x a m p l e 1 : http://example.org/v1.0/Observations? $resultFormat=dataArray $resultFormat=dataArray Great for performance! Reduce response time and data size.
  26. 26. $orderby • Example 1: http://examples.com/v1.0/ Observations?$orderby=result returns all Observations ordered by the result property in ascending order.
  27. 27. Example 1: http://example.org/v1.0/Things?$top=5 returns only the first five entities in the Things collection. Example 2: http://example.org/v1.0/Observations?$top=5& $orderby=phenomenonTime desc returns the first five Observation entries after sorted by the phenomenonTime property in descending order. Note: if the $top value exceeds the service-driven pagination limitation (i.e., the largest number of entities the service can return in a single response), the $top query option should be discarded and the pagination limitation shall be imposed. $top
  28. 28. The $skip system query option specifies a non-negative integer n that excludes the first n items of the queried collection from the result. The service returns items starting at position n+1. 
 Example 1: http://example.org/v1.0/Things?$skip=5 returns Thing entities starting with the sixth Thing entity in the Things collection. Where $top and $skip are used together, $skip SHALL be applied before $top, regardless of the order in which they appear in the request. If no unique ordering is imposed through an $orderby query option, the service SHALL impose a stable ordering across requests that include $skip. $skip
  29. 29. A URI with a $filter query option identifies a subset of the entries from the collection of entries identified by the resource path of the URI. The subset is determined by selecting only the entries that satisfy the predicate expression specified by the $filter. The value of the $filter option is a Boolean expression. The expression language that is used in $filter operators supports references to properties and literals. The literal values can be strings enclosed in single quotes, numbers and boolean values (true or false) or datetime values represented as ISO 8601 time string. $filter
  30. 30. Service-driven Paging • @iot.nextLink
  31. 31. Connect Your Arduino • Instruction and Source Code: • https://sensorup.atlassian.net/wiki/display/SPS/ 2015/12/02/SensorThings+API+-+Arduino+101
  32. 32. Useful Resources • SensorThings API Playground • http://pg.sensorup.com • API Documentation • http://www.sensorup.com/docs
  33. 33. sensorup.com@sensorup Any Questions? See You Next Week!

×