1Proprietary and Confidential AirVantage API – Getting started David SCIAMMA – June 13th 2014
2Proprietary and Confidential How can I integrate AirVantage? 2 Enterprise systems Desktop/Web/Mobile apps Your remote assets RESTful API
3Proprietary and Confidential Understand the concepts How to use AirVantage API step by step Use a concrete use case as an example How to use Postman What you will learn
4Proprietary and Confidential How to develop a web application How to develop an Android or iOS application What you won’t learn
5Proprietary and Confidential « I want to do a first test to call AirVantage API » Where’s the documentation? Let’s start!
6Proprietary and Confidential Documentation
7Proprietary and Confidential « I want to do a first test to call AirVantage API » Let’s check I’m authenticated. Get details about me: Which tool? Let’s start! > GET
8Proprietary and Confidential Postman –
9Proprietary and Confidential « I want to do a first test to call AirVantage API » Let’s check I’m authenticated. Get details about me: How can I get a token? Let’s start! > GET
10Proprietary and Confidential Reuse the token from the user interface
11Proprietary and Confidential Reuse the token from the user interface This method should only be used for quick testing Use OAuth for real development!
12Proprietary and Confidential Create an API Client 3 flows to get a token Resource owner for really trusted application Authorization code for server-side application Implicit for client-side application Postman supports the Authorization code! Use OAuth 2.0 Specs:
13Proprietary and Confidential Request: Response: API Basics > GET { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" } { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" }
14Proprietary and Confidential REST (Representational state transfer) Base URI, such as An Internet media type (JSON, XML, RSS, CSV…) Standard HTTP methods GET - Used for retrieving resources, POST - Used for creating resources, performing custom actions, PUT - Used for updating resources or collections. DELETE - Used for deleting resources Hypertext links
15Proprietary and Confidential Request: Response: API Basics > GET { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" } { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" } HTTP VerbBase URIResource Path
16Proprietary and Confidential Request: Response: API Basics > GET { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" } { uid: "81210eca05484d34a29bc6c34dc31bf7", name: "David Sciamma", company: { uid: "97ba9e a a87152e3f4", name: "Sierra Wireless" }, profile: { uid: "df1c0f7d5f8c4db2b45978f98e1093ad", name: "Manager" } JSON Object
17Proprietary and Confidential Widely adopted Language independent Simple (set of attribute-value pairs) Types Number, String, Boolean, Array, Object, null JSON (JavaScript Object Notation)
18Proprietary and Confidential « Yeah! It was easy. Let’s use it for real now! » Let’s start!
19Proprietary and Confidential I have my greenhouse connected and communicating with AirVantage. I want to leverage AirVantage API to get messages received from the greenhouses, automate some communications, analyze the data The story
20Proprietary and Confidential « I want to see the messages from my device. » List the messages received from a given system: Messages > GET
21Proprietary and Confidential « I want to see the messages from my device. » Get the content of one message: Messages > GET
22Proprietary and Confidential « I want to see the stream of values sent from my device. » List the historical values for a given data of a system: Raw data > GET targetIds={system_uid}&dataIds={data_id}&access_token={token}
23Proprietary and Confidential « I want my device to execute a command. » Send a command to given system: Send commands & track operation > POST { "systems" : { "uids" : [“{system_uid}"] }, "commandId" : “{command_id}" } > POST { "systems" : { "uids" : [“{system_uid}"] }, "commandId" : “{command_id}" }
24Proprietary and Confidential « I want to validate the command has been received and executed. » Get the details of an operation Send commands & track operation > GET
25Proprietary and Confidential « I want to validate the command has been received and executed. » Get the details of an operation Track the "state" property to know if the operation is done Track the "state" property of the different "counters" to know if it worked or not Send commands & track operation > GET
26Proprietary and Confidential « I want to be notified when the temperature is above a threshold. » Configure an alert rule Setup the "Call URL" to enable webhook notifications Alerts & Webhooks
27Proprietary and Confidential Alerts & Webhooks
28Proprietary and Confidential AirVantage will send a request on the callback URL as soon as a new alert is generated Alerts & Webhooks > POST { "name":"event.alert.rule.triggered", "date": , "content": { "alert.uid":"f04a77e306de463e919ec39c387fa016", "rule.uid":"7316ee643b b61b8ac0afa824", "target.uid":"da687e2c39d54bc391633fa9c8d4c0da" } > POST { "name":"event.alert.rule.triggered", "date": , "content": { "alert.uid":"f04a77e306de463e919ec39c387fa016", "rule.uid":"7316ee643b b61b8ac0afa824", "target.uid":"da687e2c39d54bc391633fa9c8d4c0da" }
29Proprietary and Confidential « I want to analyze the data sent by my device.» Get aggregated values of data and multiple systems Available functions: mean, max, min, standard deviation, sum of squares, count, count of occurences Aggregated data (System) > GET targetIds={system_uid1},{system_uid2}… &dataIds={data_id1},{data_id2}… &fn={aggregation_function} &access_token={token}
30Proprietary and Confidential « I want to analyze the data sent by all my devices.» Get aggregated values for data of all the systems Aggregated data (Fleet) > GET targetIds={company_uid1} &dataIds={data_id1},{data_id2}… &fn={system_aggregation_function} &fleetFn={fleet_aggregation_function} &access_token={token}
31Proprietary and Confidential Possible data visualizations
32Proprietary and Confidential What’s next?
33Proprietary and Confidential API Reference Developer Guide Developer Forum GitHub API libraries, code samples, various examples Explore, interact & contribute