This section describes the AirVantage API that can be used by devices to send data in AirVantage (southbound). If you need to use the AirVantage APIs to integrate with a Web application or enterprise software, please refer to the AirVantage northbound API here .
This article explains the different steps to create an device application (embedded or PC) using simple HTTP REST API to send data and receive commands from AirVantage.
device/messages for the communication from the device to AirVantage.device/tasks for the communication from AirVantage to the device.The
contentheader must be defined:‘Content-type’: ‘application/json’
double, int, string, boolean, binary and date.
To use this format you need to include the HTTP header “Device-REST-Version” with the value “2”.
{ "<timestamp>": { "<dataname>": <value>, "<dataname>": <value>}, ... }
Example:
<asset default-label="My Machine" id="machine">
     <variable default-label="Temperature" path="temperature" type="double"/>
     <variable default-label="Humidity" path="humidity" type="double"/>
     <setting default-label="Threshold" path="threshold" type="int"/>
</asset>
{ "1349907137000": { "machine.temperature": 23.2, "machine.humidity": 70 },
  "1349908137000": { "machine.temperature": 24.5 },
  "1349909137000": { "machine.temperature": 22.9 },
  "1349907137000": { "machine.threshold": 30}
}
As the timestamp value is optional, the format can be:
{ "machine.temperature": 23.2, "machine.humidity": 70 }
When the server will received the values, it will add a timestamp.
[
   {
      "uid" : "<uid>",
      "timestamp" : <timestamp>,
      "<command>" : ["<dataname>", ...]
    }
]
A single task can be sent at the time.
Example:
[
  {
    "uid" : "3c12547b613740adb686271bdc8f097c",
    "timestamp" : 1348836320188,
    "read" : ["machine.temperature"]
  }
]
or
[
  {
    "uid": "8006cc58ba2141f69161a78f1bfdea1d",
    "timestamp": 1348836320566,
    "write" : [{"machine.threshold" : 25}}]
  }
]
[
   {
      "uid" : "<uid>",
      "timestamp" : <timestamp>,
      "command" : {"id": "<command-id",
                   "params": {"<param-name>":"<param-value", ...}
                      }
    }
]
A single command can be sent at the time.
Example:
<asset default-label="My Machine" id="machine">
     <command path="sendMessage" default-label="send Message">
          <parameter id="message" default-label="Message" type="string" />
     </command>
</asset>
[
   {
      "uid" : "e87b35c3c2e2417b902277ff9d049d70",
      "timestamp" : 1416324560869,
      "command" : {"id": "machine.sendMessage",
                   "params": {"message":"Hello World!"}
                      }
    },
    ...
]
[ { "<dataname>": [{ "timestamp": <timestamp>, "value:" <value>}, ...], "<dataname>": ... } ]
Example:
[{
    "machine.temperature": [{
      "timestamp" : new Date().getTime(),
      "value" : "42.2"
    },
    {
      "timestamp" : new Date().getTime(),
      "value" : "24.5"
    },
    {
      "timestamp" : new Date().getTime(),
      "value" : "42.9"
    }]
  },
  {
    "machine.threshold": [{
      "timestamp" : new Date().getTime(),
      "value" : "30"
    }]
  }]
See new JSON format
Some samples are available: