=============== Query API =============== --------- Overview --------- The IoTaWatt Query API provides access to the historical data in the datalogs using a restful interface that produces a table of JSON or CSV data. The table columns can be time, IoTaWatt inputs and IoTaWatt outputs. The table rows are datalog values grouped by a fixed time period or relative time periods like days, weeks, months and years. Values can be requested for a variety of measurements such as Watts, Volts or Amps. The Query API provides data to the Graph+ utility. ------------ Query types ------------ There are two basic queries currently supported: show .... Used to obtain a list of all inputs and outputs available to the query. select ...... Used to select a set of series for a particular time period and return a table of values in JSON or CSV format. ----------------- query?show ----------------- This is the only form of the show query:: HTTP://iotawatt.local/query?show=series This query simply lists all of the available inputs and outputs along with their respective primary unit of measure. The format is always JSON. The response lists the series names that the select query will recognize. Here is a typical response from a simple configuration:: {"series":[{"name":"voltage","unit":"Volts"},{"name":"mains1","unit":"Watts"}, {"name":"mains2","unit":"Watts"},{"name":"solar","unit":"Watts"}, {"name":"heat_pump","unit":"Watts"},{"name":"mains","unit":"Watts"}, {"name":"used","unit":"Watts"}]} ------------ query?select ------------ select=[*series1* [, *series2* ...]] ..................................... Required parameter. Specifies the series to be returned in the columns of the response. There are three types of series that can be requested: time [ **.local** | .utc] [ **.iso** | .unix] Returns the time of the beginning of the reporting group. Modifiers can be used to specify local (default) or utc time, and iso date format(default) or unix seconds since 1/1/1970 format. [ **.volts** | .hz] [.d] A voltage input or output. A unit modifier can be used to specify: * .volts (default) * .hz (frequency). The .d modifier overides the default number of decimal digits. [ **.watts** | .amps | .wh | .va | .var | .varh | .pf] [.d] A power input or output. A unit modifier can be used to specify: * .watts (default) * .amps * .wh (watt-hours) * .va (volt-ampere) * .var (volt-ampere-reactive) * .varh (volt-ampere-reactive hours) * .pf (power factor) The .d modifier overides the default number of decimal digits. An example might be: `select=[time.local.unix,mains.watts.d0,solar.wh.d1]` &begin=