robinpowered / robin-js-sdk-public

Robin Javascript SDK
https://docs.robinpowered.com
Apache License 2.0
1 stars 3 forks source link
javascript robin sdk

Robin JavaScript SDK

A JavaScript SDK to communicate with the Robin platform.

This SDK provides the ability to communicate both with the Robin API and the Robin Grid.

Installation

node

npm install git@github.com:robinpowered/robin-js-sdk.git --save will save this to the dependencies section of your package.json

You may then require this sdk as follows:

var Robin = require('robin-js-sdk');
browser

Include the script from https://static.robinpowered.com/js/sdk/$version/robin.browser.min.js, where $version is the npm version number in package.json. robin-js-sdk will be automatically attached to the window object as window.Robin.

Instantiation

robin-js-sdk is instantiated with two arguments, the first is a Robin Access Token. The second is an optional argument that can be null, a string, an object or undefined.

Options

If the second argument is undefined or null, this SDK will be instantiated with endpoints pointing to production.

If it is a string, it must be a valid robin endpoint. Valid values are test, staging or production. Otherwise an error is thrown.

If it is an object:

Robin API

The Robin API is a REST based API. Calls to the API return a promise.

Core API Routes:

Route Source
Accounts accounts.js
Apps apps.js
Auth auth.js
Channels channels.js
DeviceManifests devicemanifests.js
Devices devices.js
Identifiers identifiers.js
Locations locations.js
Me me.js testMe.js
Organizations organizations.js
Projects projects.js
Spaces spaces.js
Triggers triggers.js
Users users.js

Places API Routes:

Route Source
Events events.js

Robin Grid

TODO: Improve this section in a future PR

The Grid is a websocket server that allows PubSub between clients and devices through configured channels. The Grid module is an EventEmitter, to allow real-time updates.

The Grid exposes several modules, which allow you to connect and listen:

Development Roadmap

The following should be implemented:

Browserify

Running grunt browser generates two files in the browser/ folder.