Skip to content

Examples

LiamMcNamara edited this page Nov 11, 2013 · 34 revisions

This page lists some simple ways to interact with the SicsthSense system via command line (such as with cURL). This behaviour can be very easily implemented in the programming language of your choice. Examples just use HOST as placeholder for the hostname of the service you are using (probably either sense.sics.se or localhost if you are running your own copy).

Register a user

$ curl -X POST -H "Content-Type: application/json" \
 -d '{"username":"alice", "email":"alice@wonderland.com"}' http://HOST:8080/users

This will return the USERID of the new user.

Register a new resource for the user

A new resource can then be registered for polling and/or posting:

$ curl -X POST -H "Content-Type: application/json" \
 -d '{"label": "resourceLabel", "polling_url":"http://datasource.com/test.json", "polling_period":100}' \
 http://HOST:8080/users/USERID

This will return the RESOURCEID of the new resource.

Post some data

Post a JSON data file and have the resource automatically create corresponding parsers and output streams.

$ curl -XPOST -H "Content-Type: application/json" \
 -d '{"temperature": 20.1, "humidity": 10}' http://HOST:8080/users/USERID/resources/RESOURCEID/data

Alternatively a stream can be posted to directly, without being interpreted by any parsers. This will require the use of some simple formatting for the JSON data file.

$ curl -XPOST -H "Content-Type: application/json" \
 -d '{"value": 20.1, "time": 10}' http://HOST:8080/users/USERID/resources/RESOURCEID/streams/STREAMID/data

To make the posting process more efficient, a stream can be posted to using atmosphere websockets just send the JSON to the corresponding url: http://HOST:8080/users/USERID/resources//RESOURCEID/streams/STREAMID/ws

Retrieve data

$ curl http://HOST:8080/users/USERID/resources/RESOURCEID/streams/STREAMID/data

Clone this wiki locally