Pushing and retrieving data
Publish sensor updates and retrieve data from a stream.
These examples document the original platform. Use your own deployment; this website does not provide the former hosted API or account service.
This is the simplest way to get data published on servIoTicy, or to access others’ public data also.
Important Format Restrictions:
The lastUpdate field in a sensor update is a timestamp (unix time, epoch) and therefore must be a long
For spatial queries, a channel named location with type ‘geo_point‘ must be added to the stream, and the field current-value of the location channel must be a string that represents the latitude and longitude as comma separated values: “34.5445 , 3.5533″
The field current-value of every channel is the only field that can be used for data composition, and it must be a string, numeric or boolean json value. No nested json documents are accepted.
servIoTicy API reference available at docs.servioticy.com
API REFERENCEPublish data
If you want to publish data in this format
{
"channels": {
"location": {
"current-value": "50.818395, 4.40313"
}
},
"lastUpdate": 1199192935
}You can send it with this command
curl -i -X PUT -H "Content-Type: application/json" \
-H "Authorization: YOUR_API_TOKEN" \
-d @data.json http://api.servioticy.com/139403523318497be978754164c27b07e748b53079662/streams/positionAnd get this positive response
HTTP/1.1 202 Accepted
Date: Thu, 03 Apr 2014 12:00:37 GMT
Server: api.servIoTicy
Content-Type: application/json
Transfer-Encoding: chunked
{"channels":{"location":{"current-value":"50.818395, 4.40313"}},"lastUpdate":1199192935}Retrieving data from the platform
With your API TOKEN and the SOID, you can retrieve all data published for the sensor with the following call
curl -i -H "Authorization: YOUR_API_TOKEN" \
http://api.servioticy.com/139403523318497be978754164c27b07e748b53079662/streams/positionAnd this is what you get
HTTP/1.1 200 OK
Date: Thu, 03 Apr 2014 12:10:13 GMT
Server: api.servIoTicy
Content-Type: application/json
Transfer-Encoding: chunked
{ "data": [{"channels":{"location":{"current-value":"50.818395, 4.40313"}},"lastUpdate":1199192935}, {"channels":{"location":{"current-value":"51.818395, 4.50313"}},"lastUpdate":1199192940}, {"channels":{"location":{"current-value":"51.918395, 4.46313"}},"lastUpdate":1199192945}] }You can add several modifiers to the retrieve operations to perform more accurate queries, as described in this section!
