TempoDB - Time Series Cloud DB service

This looks interesting tempo-db.com

Interview with founder covers why they built it

looks cool.
love to see an Imp client example, like the COSM node, because I still have a problem writing in Squirrel :frowning:

I still have a problem writing in Squirrel
Me too but I had a play with the API using RESTman a Chrome App and got it working. Looking at the Agent object example in Wiki for Twillo would be the starting point for building the API http://devwiki.electricimp.com/doku.php?id=electricimpapi:agent

What I like about this service is they are serious about doing one thing really well.
They also have a basic set of functions, mean, sum etc. Their meta data works well with what we want to do. And they replicate across more than 3 data centres.

I had a play with the API using RESTman a Chrome App and got it working
Thanks for that suggestion Still waiting for those Agents :-(

tempo-db works quite well with the Agents - in initial testing.

I have some example code for writing and reading to a tempo-db database. The code is really bare but it does the basics. I have just been writing a couple of data points and then reading data back out.

When you sign up your account will have a test database with a pre-populated data series titled “demo-series”. You can use their API console to test reading this data in the browser before writing agent code. In my database I also added a series called “testnew” so I could play with writing data to a new series through the imp Agent.

The database has a Key and a Secret that you use like a username and password in the API console. This is also used to do basic authorization in the http request.

hope it helps.


NOTE: there are a ton of server logs here. I suggested commenting most of them out at
the start and un-comment as you progress. otherwise the log is a bit overwhelming.

_TempoDBurl <- “https://api.tempo-db.com/v1”;

function getBasicAuthHeader(user, password) {
local headers = {
“Authorization” : "Basic " + http.base64encode(user + “:” + password)
return headers;


TempoDBheaders <- getBasicAuthHeader(APIKey,APIsecret);
TempoDBheaders[“Connection”] <- “Keep-Alive”;
TempoDBheaders[“Host”] <- “api-tempo-db.com”;
TempoDBheaders[“X-Target-URI”] <- “https://api-temp-db.com”;
TempoDBheaders[“Content-Type”] <- “application/json”;


function HttpGetWrapper (apiurl) {

local request = http.get((_TempoDBurl + apiurl), TempoDBheaders);//, string);

local response = request.sendsync();
return response;

function HttpPostWrapper (apiurl, body) {

local request = http.post(_TempoDBurl + apiurl, TempoDBheaders,body);

local response = request.sendsync();
return response;

datatosend <- [];

datatosend.append({ t = “2013-11-08T00:01:23.000+0000” , v = 95.6});
datatosend.append({ t = “2013-11-08T00:08:15.000+0000”, v = 92.3});


server.log("length is " + datatosend.len());


function TempoDBpostRequest(){

local api = "/series/key/testnew/data/";

local postresponse = HttpPostWrapper(api,http.jsonencode(datatosend));

server.log("    ...response");
server.log("    .body ");

server.log(" ");

foreach(idx,val in postresponse){
      agentlog("resp-index= "+idx+" value= "+val+"\

foreach(idx,val in postresponse.headers){
agentlog(“headers-index= “+idx+” value= “+val+”


function TempoDBgetRequest(){

//you MUST change this to represent the day of your data series.

local api=  "/series/key/demo-series/data/?start=2013-11-01&end=2013-11-02&interval=1hour";

//here is another example
//local api=  "/series/key/testnew/data/?start=2013-11-08&end=2013-11-09&interval=1min";

local _response = HttpGetWrapper(api);//response is a squirrel table

server.log("<>myresponse<>" + _response); //This returns "table : 0x".....

server.log("JSON.response: " + http.jsonencode(_response));//returns valid JSON, body is JSON
server.log("JSON.response.body: " + http.jsonencode(_response.body));//returns string that is not valid JSON
server.log("response.body: " + _response.body);//returns valid JSON
http.jsondecode(_response.body);//is a squirrel table

foreach(idx,val in _response){
      server.log("myrsponse<> "+idx+":"+val+"\

//returns headers, statuscode and body

foreach(idx,val in _response.headers){

//returns server, connection, date, content-length

local responsebody = http.jsondecode(_response.body);

foreach(idx,val in responsebody){
      server.log("<responsebody>  "+idx+" : "+val+"\


        rollup (table)
        series (table)
        summary (table)
        data (array)
foreach(idx,val in responsebody.rollup){
      server.log("<rollup>"+idx+" : "+val+"\

… I think this would be depend on what you request
foreach(idx,val in responsebody.series){
server.log(”"+idx+" : “+val+”
key : demo-series
tags : (array)
attributes: (table)
… I think this would be depend on what you request

local responsebodydata = responsebody.data;//is an array

local valuereturned = 0.0;

for(local a=0;a<responsebodydata.len();a+=1){
  valuereturned = responsebodydata[a].v
  server.log("<data>"+"t:"+ responsebodydata[a].t +" v:" + valuereturned + "\


  //returns 24 data points because the interval is set to 1 hour and because the
  //sample dataset covers a period of 1 day.


//delay running in hopes of keeping the log more clean - my log messages were getting intermixed in time.

//Only do one of these at a time

@mjkuwp94 thanks for this good work. How have you got on with the query language? it seems similar to other NoSql syntax. Are you planing to render to Highcharts?

Thanks @controlCloud. I do plan to use Highcharts to render the data at some point. I think the hard part for me will be laying out the controls on a web page to choose the date and time windows and intervals. The API for TempoDB seems straightforward enough.

I am not totally sure what you mean by the “query language”. Are you referring to the language of pulling data from TempoDB - meaning building the url string?

I am glad you mentioned NoSql. I had not heard that term before so I went to Wikipedia to check it out. I have done a little bit of database work back in the day with Microsoft Access and using sql commands. I understood that some newer concepts were in use but I did not have a name for it. … but that’s a tiny bit off topic.

here is one more bit that a person might need. I realize many will know how to do this straight away but I had to research what is an ISO 8601 date and then figure out how to format that in squirrel-lang. this creates a time stamp in the Agent to place on the data. maybe it would also work on the Device.

I am putting all my data in with the time stamp from the agent; apparently GMT. When I pull the data out I apply the timezone.

local api= "/series/key/" + seriesname + "/data/?start=2013-11-09&end=2013-11-10&interval=1min&tz=America/Chicago"

function iso8601 (){

local d = date();

return format("%02d-%02d-%02dT%02d:%02d:%02d",d.year,d.month+1,d.day,d.hour,d.min,d.sec);


From my IDE log, here is one data point having been entered
2013-11-10 06:29:27 UTC-6: [Agent] device sent 21.3225
2013-11-10 06:29:27 UTC-6: [Agent] status code was 200

and then pulled out from TempoDB using the America/Chicago timezone stamp. The correct time is shown and it is also listed as “-6:00” - 6 hours behind GMT as I am.

again, obvious for some but not all who may read this. this concept was new to me.

2013-11-10 06:38:21 UTC-6: [Agent] t:2013-11-10T06:29:00.000-06:00 v:21.3225

@mjkuwp94 I’m too a vetran of the M$ Access and like one two others impers Dbase.

Re-reading the tempoDB docs I can see it’s very simple with nosql db’s you have same issue around correct formatting of time stamps. I tried mongoDB and it wasn’t obvious how you did between date range queries but a bit googling sorted that.

I don’t use controls any more for building up query/api parameter to retrieve and render my charts. I use a query string
I’m happy to share my PHP it’s is not hot but is UTC time based.

I need to do a bit of work on tempoDB tags and attributes as I use a the following model to manage different sites. https://tempo-db.com/docs/modeling-time-series-data/
As my imps and other devices are located at multiple locations. Model: siteID.DeviceID.DataAttributeID 200.53.1 is which is imp temp reading from my kitchen .1 is “temp high alert” in the charts qs above site=200 and two devices d=53:54

I specify date/time query periods in two ways Duration dr: which is a multiple of 12 hours from “now” or a start & end date for looking at data from a given day


@controlCloud, thanks for the detailed response.

I am curious about your use of PHP. Are you doing this because TempoDB has provided a library for this? In their documentation they state they have clients for many languages. I am not sure why they use that terminology as I think of this as a library to simplify using their product.

I do not know PHP so I have a soft goal of developing my stuff without using PHP. The Agents seem to do the job.

I currently pay for hosting on hostgator but I am using that less and less. I am not sure if this is wise or not. do you know any website hosting that includes anything like what TempoDB offers (apparently NoSQL data storage)? I would feel a bit more secure if I was a paying customer of TempoDB but their paid tier is a gigantic leap from the free one.

Hey there, my name’s Matt and I’m a Solutions Architect at TempoDB. It’s really neat to see how you’ve used our service in your projects! If any of you have any questions, feel free to shoot me an email at matt.meshulam (at) tempo-db (dot) com.

Also, we’re always looking for cool projects that use TempoDB to feature on our blog. So if you have something you’d like to share, I’d be happy to hear from you!