Cosm History
Attempts to implement cosm js library to pull the last 10 items from the history and save it to an array.
HTML
<script src="http://d23cj0cdvyoxg0.cloudfront.net/cosmjs-1.0.0.min.js"></script>
<body>
<ul id="stuff">
</ul>
</body>
JavaScript
cosm.setKey("-Ux_JTwgP-8pje981acMa5811-mSAKxpR3VRUHRFQ3RBUT0g"); //read only key
var cosmFeed = 120687;
var cosmDataStream = "sensor_reading";
$(document).ready( function() {
var success = function(data){
for(var datapoint in data.datapoints){
var dp = data.datapoints[datapoint];
$('#stuff').append('<li>Value: ' + dp.value + ' At: ' + dp.at + '</li>');
}
}
//Print out the last 10 readings or so
cosm.datastream.history( cosmFeed, cosmDataStream, {duration:'1day'}, success );
})
//Current API documentation
//http://cosm.github.com/cosm-js/docs/
// Outdated API documentation
//http://cosm.com/docs/v2/history.html