|
| 1 | +IOStash Javascript Web Client Library |
| 2 | +=================== |
| 3 | + |
| 4 | + |
| 5 | +Javascript web Client library for IOStash IoT PaaS. Supports realtime data subscription to Devices, Data Points, Location, Channels and Custom Data sent to devices. |
| 6 | + |
| 7 | + **Including** |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + <script type="text/javascript" src="https://api.iostash.io/assets/js/iostash.js"></script> |
| 12 | + |
| 13 | + |
| 14 | + **How To Use** |
| 15 | + |
| 16 | +This library supports all realtime events supported by IOStash. Refer to API Docs on http://iostash.com for more information and guides about using this library. |
| 17 | + |
| 18 | + var iostash = require('iostash') |
| 19 | + iostash.init('X-ACCESS-TOKEN_HERE') |
| 20 | + |
| 21 | + iostash.subscribeDevice('DEVICE-ID_HERE', function (data) { |
| 22 | + //Handle data here |
| 23 | + }); |
| 24 | + |
| 25 | +**Example** |
| 26 | + |
| 27 | +This example utilises a public device defined in IOStash. |
| 28 | + |
| 29 | + var iostash = require('iostash') |
| 30 | + iostash.initPublic('5734997f8680bc62de000006') |
| 31 | + iostash.subscribeDevice('5734997f8680bc62de000006', function (update) { |
| 32 | + console.log(update) |
| 33 | + }) |
| 34 | + |
| 35 | +**Methods** |
| 36 | + |
| 37 | + |
| 38 | + - `init(x-access-token)` - Initialises the object with specified x-access-token. |
| 39 | + - `initPublic(deviceId)` - Initialises the object with a public device's ID. |
| 40 | + - `subscribeDevice(deviceId,cb())` - Subscribes to data changes from the specified device. |
| 41 | + - `unsubscribeDevice(deviceId,cb())` - Unsubscribes from the specified device. |
| 42 | + - `subscribeDataPoint(deviceId,datapoint,cb())` - Subscribes to specified datapoint of the specified device. |
| 43 | + - `unsubscribeDataPoint(deviceId,datapoint,cb())` - Unsubscribes from the specified data point. |
| 44 | + - `subscribeLocation(deviceId,cb())` - Subscribes to location data from the specified device. |
| 45 | + - `subscribeActions(deviceId,cb())` - Subscribes to device trigger action of the specified device. |
| 46 | + - `subscribeCustomData(deviceId,cb())` - Subscribes to custom data sent to the device. |
| 47 | + |
| 48 | +**Notes** |
| 49 | + |
| 50 | +- cb() refers to callbacks and they will be executed during updates. |
| 51 | +- While using `initPublic()` method for initialization, channel functions are not available. |
| 52 | +- This library does not (yet) support data pushing to IOStash. |
| 53 | + |
| 54 | +For support or assistance, drop an email to [email protected] |
0 commit comments