Documentation
API Key
cosm.setKey (newKey)
As you might know, Cosm requires an API Key to interface with the service. Just click Keys on your user menu to create or use an existing key and use the .setKey method to set the key before using any other methods. This will make sure that you can work your feeds as you intend.
Feeds
cosm.feed.get (feedID, callback(data))
cosm.feed.update (feedID, data{}, callback(data))
data{} - Object with this json structure
cosm.feed.new (data{}, callback(data))
data{} - Object with this json structure
cosm.feed.delete (feedID, callback(data))
cosm.feed.history (feedID, options{}, callback(data))
options{} - Object containing the parameters specified here
cosm.feed.list (options{}, callback(data))
options{} - Object containing the parameters specified here
cosm.feed.subscribe (feedID, callback(event, data))
cosm.feed.unsubscribe (feedID)
Datastreams
cosm.datastream.get (feedID, datastreamID, callback (data))
cosm.datastream.update (feedID, datastreamID, data{}, callback (data))
data{} - Object with this json structure
cosm.datastream.new (feedID, data{}, callback (data))
data{} - Object with this json structure
cosm.datastream.delete (feedID, datastreamID, callback (data))
cosm.datastream.history (feedID, datastreamID, options{}, callback(data))
options{} - Object containing the parameters specified here
cosm.datastream.list (feedID, callback(data))
cosm.datastream.subscribe (feedID, datastreamID, callback(event, data))
cosm.datastream.unsubscribe (feedID, datastreamID)
cosm.datastream.live (CSS selector, feedID, datastreamID)
cosm.datastream.stop (CSS selector)
Datapoints
cosm.datapoint.get (feedID, datastreamID, timestamp, callback (data))
cosm.datapoint.update (feedID, datastreamID, timestamp, value, callback (data))
cosm.datapoint.new (feedID, datastreamID, data{}, callback (data))
data{} - Object with this json structure
cosm.datapoint.delete (feedID, datastreamID, timestamp or options{}, callback (data))
If you want to delete multiple datapoints, pass an object instead of a timestamp with keys specified here.
cosm.datapoint.history (feedID, datastreamID, options{}, callback(data))
options{} - Object containing the parameters specified here
Request
cosm.request (options{}, callback (data))
- type: [string] example: "get"
- url: [string] example: "http://api.cosm.com/v2/feeds/504.json"
- done: [function] Callback for successful response, receives JSON response as only argument
- fail: [function] Callback for failed response, receives JSON response as only argument
- always: [function] Callback for any response, receives JSON response as only argument
This is the underlying request gateway that most methods use, it essentially makes sure everything is sent properly.
Socket Server (beta)
cosm.subscribe (resource, callback(event, data))
cosm.unsubscribe (resource)
cosm.live (CSS selector, resource)
cosm.stop (CSS selector)
Subscribe to the socket server (beta) via WebSocket. Info on the resource argument is here.
jQuery Plugin
$(selector).cosm (method, options)
- get
- live
- feed: [string] Feed ID
- datastream: [string] Datastream ID