Export Data

A REST API

With some variations, this API will be a JSON, REST based API making use of HTTP methods and paths that point to resources.
Endpoint

The endpoint for all API requests on this version of the API is:

https://api.leftronic.com/v2/

Authentication

All requests to the API will require authentication. Authentication is accomplished with your account's Access Key which you will find in any configuration window for a widget. This access key must be applied to every request in the path after the API version. For example:  

https://api.leftronic.com/v2/YOUR_ACCESS_KEY/

Errors

In case of an error the HTTP status will be set to a non-200 HTTP status. An authentication error will be a 403 error, a lookup for a widget that does not exist will be a 404, a server error will be a 500 and so on. In addition an 'error' property should be available on all responses on which there is an error and a message property should be available on all 200 OK responses.

The Outbound Data API

The initial early preview features an outbound data API which will enable the ability to retrieve any of the data we store for a widget via the API. You could use this information to augment your dashboard with alerts or generate reports for example. The data for all of the integrations will be returned mostly in the same format, varying only by widget type, allowing for an easy means to access data without having to write different code for all of these APIs. We have already done the heavy lifting and now you can take advantage of it.
Decimation

Currently and for the forseeable future, we periodically simplify the data we store for display purposes. Our dashboards were created to display recent data and due to this we priortize more recent information. We run a daily scheduled task that reduces the granularity of old data. We call this decimation. The further back in time you go the less granular the information we store, priortizing interesting highs and lows. If you need all of the information we have ever collected you will want to query this API on a daily basis to avoid the loss of information.

Methods

GET /datastream/STREAM_NAME

Fetch data for data for a widget. The STREAM_NAME is the name of the stream and can be found in the configuration window for a widget.

Examples

https://api.leftronic.com/v2/ACCESS_KEY/datastream/STREAM_NAME
https://api.leftronic.com/v2/ACCESS_KEY/datastream/STREAM_NAME?since=0
https://api.leftronic.com/v2/ACCESS_KEY/datastream/STREAM_NAME?since=1362666866

Parameters

since

The since parameter takes a UNIX time value in seconds. It will return values for the widget since that time, but not values with that time. A value of 0 will return all values available for that widget. Excluding the since will return only the most recent value.

Response

The response format will vary by widget type but responses generally follow the following format for 200 OK responses. Both a message and a data property will be available. A ts property indicates a time value you can use to fetch additional data later via the since parameter.

{
  "message" : "OK",
  "data" : [
    {
      "ts" : 1362582924.020139,
      "point" : {
        "number" : 2766
      }
    }
  ]
}
{
  "message" : "OK",
  "data" : [
    {
      "ts" : 1362318898.027542,
      "point" : {
        "msg" : "HAPPY PLATYPUS DAY EVERY ONE",
        "imgUrl" : "https://si0.twimg.com/profile_images/2827937668/41bb3fab33d4724f673927916b2a6f70_normal.jpeg",
        "title" : "blowery"
      }
    },    {
      "ts" : 1362318898.027759,
      "point" : {
        "msg" : "RT @radyrad88: Anyone need cool dashboards for lots of different data sources check out @LeftronicCo - very cool :)",
        "imgUrl" : "https://si0.twimg.com/profile_images/1566119024/post01-01_normal.png",
        "title" : "LeftronicCo"
      }
    }
  ]
}