JSON/REST API released
by
on
Flukso announces the immediate availability of its JSON/REST API at the 2010 CeBit exhibition in Hannover. Fluksonians are now able to retrieve time series data of their electricity sensors through the Flukso API. Let's start with a working example:
curl -k -v -X GET -H "Accept: application/json" -H "X-Version: 1.0"
-H "X-Token: d8a8ab8893ea73f768b66b45234b5c3a"
"https://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?interval=hour&unit=watt"
Where:
- X-Version: Denotes the desired API version. Should be set to 1.0.
- X-Token: A token associated with the specific sensor id. Different tokens per sensor will allow for varying access permissions, e.g. only allow data in 'month' resolution. This feature will become available in the near future. We now provision a single token per sensor. The token can be found next to its respective sensor id (see below).
- Sensor: Your sensor id's are displayed under the 'my account' -> 'sensor' tab. Just substitute the above sensor id and token with your own and you're ready to go.
- Interval: Should be one of {hour, day, month, year, night}
- Unit: Should be one of {watt, kwhperyear, eurperyear, audperyear}
Data is returned as an array of [unix timestamp, value] tuples, where value will be reported as a "nan" string when no data is available for the interval.
[[1267802160,69], [1267802220,69], [1267802280,73], ... , [1267805760,"nan"]]
The unix timestamp denotes the end of the interval for which the value is reported. So in the above example [1267802220,69] means that in the one-minute interval [1267802160, 1267802220] 69 watts of electricity has been consumed.
Thanks to Geert and Mathias for their valuable feedback during alpha testing.
Have fun!
Update 15/03/10: Added info on where to retrieve token information.