keen-event-client
A lightweight wrapper for dealing with the Keen.io event API.
Although Keen.io has an extensive JS SDK, I experienced problems using it on the Tessel 1 board.
Install with:
npm install keen-event-client
Usage
var keen = ; var client = keen;var event = temp: 7489 rh: 5217; keen;
API
All callbacks are called with arguments err, data, res
.
err
is the error object, if any, otherwise null.data
is the object deserialized from JSON that was returned by the keen.io API. This may be null if the request did not return data.res
is the response object itself.
keen.createClient(options)
Returns an object initialized with the supplied options
object. All operations performed by the instance of the client are against the keen.io project specified by options.projectId
and will use the keys specified by options.writeKey
or options.readKey
.
Required:
projectId
keen.io project IDwriteKey
keen.io write keymasterKey
keen.io master key
Optional:
urlBase
defaults tohttps://api.keen.io
version
defaults to3.0
keen.addEvent(collection, event, callback)
Inserts a single event
into the specified collection
.
Example event
:
temp: 7234 rh: 5883
keen.addEvents(events, callback)
Inserts multiple events
into one or more collections. events
should be an object with properties, which are the names of collections. The values of these properties should be arrays of objects, which are the events.
events
example:
climate: temp: 7234 rh: 5883 temp: 7159 rh: 5796 ambient: soundLevel: 043 lightLevel: 039
keen.getEvent(collection, callback)
Returns the schema information for the collection
.
data
example:
properties: temp: 'num' rh: 'num'
keen.getEvents(callback)
Returns the schema information for all collections in the project specified by options.projectId
.
data
example:
name: 'climate' url: '/3.0/projects/YOUR_PROJECT_ID/events/climate' properties: 'client.id': 'string' 'client.created_at': 'datetime' temp: 'num' rh: 'num' name: 'ambient' url: '/3.0/projects/YOUR_PROJECT_ID/events/ambient' properties: 'client.id': 'string' 'client.created_at': 'datetime' soundLevel: 'num' lightLevel: 'num'