-
Notifications
You must be signed in to change notification settings - Fork 8
Examples
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).
$ 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.
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 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
$ curl http://HOST:8080/users/USERID/resources/RESOURCEID/streams/STREAMID/data