User Tools

Site Tools


access_via_api

There is Excel VBA scripts codes example here

Using API

With WebHMI, you can interact with REST-like programming interface (API).

The API provides access to all the basic functions necessary for data collection and system management. Calling the API method is an HTTP request to the сertain URL with the required parameters. The following methods are available:

All data is returned in the format JSON. Some parameters must be passed as part of the URL (usually an event ID, register, etc.). The remaining parameters are passed in the form of HTTP request headers (time interval, API Key and others). For more details, see the description of the specific method.

To ensure the security and delineation of access rights, the API access keys are used (API Keys).

The WebHMI device has an API sandbox. It is available at the address http://192.168.1.1/api-docs/. This is a mini version of the API documentation with the ability to execute any query directly from the browser and see the result of its work.

Connection list

To get a list of all connections, you must perform a GET request on the URL like this: http://192.168.1.1/api/connections.

To obtain information about a particular connection, you must perform a GET request on a URL like this: 'http://192.168.1.1/api/connections/1' . Here “1” is the ID of the desired connection.

In the request headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json

Content-Type: application/json

Note that, if you are using another WebHMI as client (via cURL Lua's library), the following line should be removed

Accept-Encoding: gzip, deflate, sdch

Example of a connection list request:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of a response:

[
  {
    "id": "1",
    "title": "Internal registers",
    "addr": "",
    "baudrate": "9600",
    "parity": "e",
    "stopbit": "1",
    "bitscount": "8",
    "model": "3",
    "protocol": "4",
    "timeout": "100",
    "timeout2": "",
    "device": "/dev/rs485",
    "disabled": "0",
    "mode": "0"
  },
  {
    "id": "2",
    "title": "S7 200",
    "addr": "2",
    "baudrate": "9600",
    "parity": "e",
    "stopbit": "1",
    "bitscount": "8",
    "model": "1",
    "protocol": "3",
    "timeout": "200",
    "timeout2": "",
    "device": "/dev/rs485",
    "disabled": "1",
    "mode": "0"
  }
]

Example of a request for connection #2 information:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of a response:

{
  "id": "2",
  "title": "S7 200",
  "addr": "2",
  "baudrate": "9600",
  "parity": "e",
  "stopbit": "1",
  "bitscount": "8",
  "model": "1",
  "protocol": "3",
  "timeout": "200",
  "timeout2": "",
  "device": "/dev/rs485",
  "disabled": "1",
  "mode": "0"
}
Connection attributes:
id int Unique connection Id
title string Connection name
addr string Bus address or network address for TCP connection
baudrate int Communication speed for serial connections
parity string Parity check for serial connections. e = Even, o = Odd, n = None
stopbit int Number of stop bits for serial connectoins
model int Id of the device type
protocol int Id of the communication protocol
timeout int Maximal timeout for waiting response from device
device string System adapter name of the serial connections
disabled int 0 = connection is active, 1 = connection is disabled
mode int 0 = normal mode. 1 = Virtual UART mode

Id of the device type:

0 Delta DVP
1 Siemens Simatic S7 200
2 Generic ModBus
3 Internal WebHMI Registers
4 Generic Owen
5 Generic DF1

Ids of the communication protocols:

0 ModBus ASCII
1 ModBus RTU
2 ModBus TCP
3 Siemens PPI
4 Owen
5 Allen Bradley DF1
6 Internal WebHMI Registers

Register list

To get a list of all registers, you must perform a GET request on the URL like this: http://192.168.1.1/api/registers.

To obtain information about a particular register, you must perform a following GET request on a URL 'http://192.168.1.1/api/registers/1' . Here “1” is the ID of the desired register.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DAB

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of register list query:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

[
  {
    "id": "1",
    "plcid": "2",
    "title": "Packing is in progress",
    "addr": "M1.0",
    "modbusAddr": "",
    "type": "0",
    "dictid": "0",
    "value_format": "0",
    "multiplicator": "",
    "shift": "",
    "save_to_log": "0",
    "measureUnits": "",
    "has_normal": "0",
    "normal_regid": "0",
    "normal_regid2": "0",
    "normal_dynamic_value": "0",
    "normal_binary_value": "",
    "normal_binary_text": "",
    "normal_color": "#33d356",
    "normal_min_regid": "-1",
    "normal_min_delta": "",
    "normal_max_regid": "-1",
    "normal_max_delta": "",
    "normal_min_val": "",
    "normal_max_val": "",
    "has_disabled": "0",
    "disabled_regid": "0",
    "disabled_regid2": "0",
    "disabled_dynamic_value": "0",
    "disabled_binary_value": "",
    "disabled_binary_text": "",
    "disabled_color": "#cccccc",
    "disabled_min_regid": "-1",
    "disabled_min_delta": "",
    "disabled_max_regid": "-1",
    "disabled_max_delta": "",
    "disabled_min_val": "",
    "disabled_max_val": "",
    "has_warning": "0",
    "warning_regid": "0",
    "warning_regid2": "0",
    "warning_dynamic_value": "0",
    "warning_binary_value": "",
    "warning_binary_text": "",
    "warning_color": "#f0b417",
    "warning_min_regid": "-1",
    "warning_min_delta": "",
    "warning_max_regid": "-1",
    "warning_max_delta": "",
    "warning_min_val": "",
    "warning_max_val": "",
    "has_alert": "0",
    "alert_regid": "0",
    "alert_regid2": "0",
    "alert_dynamic_value": "0",
    "alert_binary_value": "",
    "alert_binary_text": "",
    "alert_color": "#ee434d",
    "alert_min_regid": "-1",
    "alert_min_delta": "",
    "alert_max_regid": "-1",
    "alert_max_delta": "",
    "alert_min_val": "",
    "alert_max_val": "",
    "timeformat": "Y-m-d H:i:s",
    "log_tolerance": "",
    "precision_digits": "",
    "min_log_interval": "",
    "max_log_interval": "",
    "max_graph_interval": "",
    "max_allowed_value": "",
    "min_allowed_value": "",
    "rw_mode": "",
    "min_reasonable_value": "",
    "max_reasonable_value": "",
    "save_graph_data": "0",
    "graph_interval": "1",
    "graph_color": "#ff0000",
    "disabled": "0",
    "nocloud": "",
    "delta": "0",
    "delay": "0"
  },
  {
    "id": "2",
    "plcid": "2",
    "title": "Recipe",
    "addr": "VW100",
    "modbusAddr": "",
    "type": "2",
    "dictid": "1",
    "value_format": "0",
    "multiplicator": "",
    "shift": "",
    "save_to_log": "0",
    "measureUnits": "",
    "has_normal": "0",
    "normal_regid": "0",
    "normal_regid2": "0",
    "normal_dynamic_value": "0",
    "normal_binary_value": "",
    "normal_binary_text": "",
    "normal_color": "#32d355",
    "normal_min_regid": "-1",
    "normal_min_delta": "",
    "normal_max_regid": "-1",
    "normal_max_delta": "",
    "normal_min_val": "",
    "normal_max_val": "",
    "has_disabled": "0",
    "disabled_regid": "0",
    "disabled_regid2": "0",
    "disabled_dynamic_value": "0",
    "disabled_binary_value": "",
    "disabled_binary_text": "",
    "disabled_color": "#cccccc",
    "disabled_min_regid": "-1",
    "disabled_min_delta": "",
    "disabled_max_regid": "-1",
    "disabled_max_delta": "",
    "disabled_min_val": "",
    "disabled_max_val": "",
    "has_warning": "0",
    "warning_regid": "0",
    "warning_regid2": "0",
    "warning_dynamic_value": "0",
    "warning_binary_value": "",
    "warning_binary_text": "",
    "warning_color": "#f0b416",
    "warning_min_regid": "-1",
    "warning_min_delta": "",
    "warning_max_regid": "-1",
    "warning_max_delta": "",
    "warning_min_val": "",
    "warning_max_val": "",
    "has_alert": "0",
    "alert_regid": "0",
    "alert_regid2": "0",
    "alert_dynamic_value": "0",
    "alert_binary_value": "",
    "alert_binary_text": "",
    "alert_color": "#ee434d",
    "alert_min_regid": "-1",
    "alert_min_delta": "",
    "alert_max_regid": "-1",
    "alert_max_delta": "",
    "alert_min_val": "",
    "alert_max_val": "",
    "timeformat": "Y-m-d H:i:s",
    "log_tolerance": "",
    "precision_digits": "",
    "min_log_interval": "",
    "max_log_interval": "",
    "max_graph_interval": "",
    "max_allowed_value": "",
    "min_allowed_value": "",
    "rw_mode": "",
    "min_reasonable_value": "",
    "max_reasonable_value": "",
    "save_graph_data": "0",
    "graph_interval": "1",
    "graph_color": "#ff0000",
    "disabled": "0",
    "nocloud": "",
    "delta": "0",
    "delay": "0"
  },
  {
    "id": "3",
    "plcid": "2",
    "title": "Packs counter",
    "addr": "С1",
    "modbusAddr": "",
    "type": "3",
    "dictid": "0",
    "value_format": "0",
    "multiplicator": "",
    "shift": "",
    "save_to_log": "0",
    "measureUnits": "",
    "has_normal": "0",
    "normal_regid": "0",
    "normal_regid2": "0",
    "normal_dynamic_value": "0",
    "normal_binary_value": "",
    "normal_binary_text": "",
    "normal_color": "#33d356",
    "normal_min_regid": "-1",
    "normal_min_delta": "",
    "normal_max_regid": "-1",
    "normal_max_delta": "",
    "normal_min_val": "",
    "normal_max_val": "",
    "has_disabled": "0",
    "disabled_regid": "0",
    "disabled_regid2": "0",
    "disabled_dynamic_value": "0",
    "disabled_binary_value": "",
    "disabled_binary_text": "",
    "disabled_color": "#cccccc",
    "disabled_min_regid": "-1",
    "disabled_min_delta": "",
    "disabled_max_regid": "-1",
    "disabled_max_delta": "",
    "disabled_min_val": "",
    "disabled_max_val": "",
    "has_warning": "0",
    "warning_regid": "0",
    "warning_regid2": "0",
    "warning_dynamic_value": "0",
    "warning_binary_value": "",
    "warning_binary_text": "",
    "warning_color": "#f0b417",
    "warning_min_regid": "-1",
    "warning_min_delta": "",
    "warning_max_regid": "-1",
    "warning_max_delta": "",
    "warning_min_val": "",
    "warning_max_val": "",
    "has_alert": "0",
    "alert_regid": "0",
    "alert_regid2": "0",
    "alert_dynamic_value": "0",
    "alert_binary_value": "",
    "alert_binary_text": "",
    "alert_color": "#ee434d",
    "alert_min_regid": "-1",
    "alert_min_delta": "",
    "alert_max_regid": "-1",
    "alert_max_delta": "",
    "alert_min_val": "",
    "alert_max_val": "",
    "timeformat": "Y-m-d H:i:s",
    "log_tolerance": "",
    "precision_digits": "",
    "min_log_interval": "",
    "max_log_interval": "",
    "max_graph_interval": "",
    "max_allowed_value": "",
    "min_allowed_value": "",
    "rw_mode": "",
    "min_reasonable_value": "",
    "max_reasonable_value": "",
    "save_graph_data": "0",
    "graph_interval": "1",
    "graph_color": "#ff0000",
    "disabled": "0",
    "nocloud": "",
    "delta": "0",
    "delay": "0"
  }
]

Example of request for information about the register number 2:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "2",
  "plcid": "2",
  "title": "Recipe",
  "addr": "VW100",
  "modbusAddr": "",
  "type": "2",
  "dictid": "1",
  "value_format": "0",
  "multiplicator": "",
  "shift": "",
  "save_to_log": "0",
  "measureUnits": "",
  "has_normal": "0",
  "normal_regid": "0",
  "normal_regid2": "0",
  "normal_dynamic_value": "0",
  "normal_binary_value": "",
  "normal_binary_text": "",
  "normal_color": "#32d355",
  "normal_min_regid": "-1",
  "normal_min_delta": "",
  "normal_max_regid": "-1",
  "normal_max_delta": "",
  "normal_min_val": "",
  "normal_max_val": "",
  "has_disabled": "0",
  "disabled_regid": "0",
  "disabled_regid2": "0",
  "disabled_dynamic_value": "0",
  "disabled_binary_value": "",
  "disabled_binary_text": "",
  "disabled_color": "#cccccc",
  "disabled_min_regid": "-1",
  "disabled_min_delta": "",
  "disabled_max_regid": "-1",
  "disabled_max_delta": "",
  "disabled_min_val": "",
  "disabled_max_val": "",
  "has_warning": "0",
  "warning_regid": "0",
  "warning_regid2": "0",
  "warning_dynamic_value": "0",
  "warning_binary_value": "",
  "warning_binary_text": "",
  "warning_color": "#f0b416",
  "warning_min_regid": "-1",
  "warning_min_delta": "",
  "warning_max_regid": "-1",
  "warning_max_delta": "",
  "warning_min_val": "",
  "warning_max_val": "",
  "has_alert": "0",
  "alert_regid": "0",
  "alert_regid2": "0",
  "alert_dynamic_value": "0",
  "alert_binary_value": "",
  "alert_binary_text": "",
  "alert_color": "#ee434d",
  "alert_min_regid": "-1",
  "alert_min_delta": "",
  "alert_max_regid": "-1",
  "alert_max_delta": "",
  "alert_min_val": "",
  "alert_max_val": "",
  "timeformat": "Y-m-d H:i:s",
  "log_tolerance": "",
  "precision_digits": "",
  "min_log_interval": "",
  "max_log_interval": "",
  "max_graph_interval": "",
  "max_allowed_value": "",
  "min_allowed_value": "",
  "rw_mode": "",
  "min_reasonable_value": "",
  "max_reasonable_value": "",
  "save_graph_data": "0",
  "graph_interval": "1",
  "graph_color": "#ff0000",
  "disabled": "0",
  "nocloud": "",
  "delta": "0",
  "delay": "0"
}

Register's attributes

Register's attributes:
id int Unique register id
title string Register name
plcid string The identifier of the associated connection of the register
addr string Register address
modbusAddr string Register address for embedded Modbus TCP server
type int Data type identifier (see below)
value_format int Data format identifier (see below)
dictid int Dictionary identifier
multiplicator double Multiplier for math conversations for the register value
shift double Constant for math conversions for the register value
save_to_log int 0 = don't save data to log, 1 = periodically save data to log
measure Units string Engineering units (meters, volts etc)
has_normal int 1 = register has normal state, 0 = not normal state
normal_regid int Identifier of the comparative register (for registers of a bit type)
normal_regid2 int Second comparative register identifier (for regisers of a bit type)
normal_dynamic_value int 1 = compare register value with values from comparative registers , 0 = compare register with constants
normal_binary_value int Binary value (1 or 0) which turns on normal register state
normal_binary_text string Text to display normal register state
normal_color string Normal state color
normal_min_regid int Minimal value register identifier for dynamic comparison
normal_min_delta string Delta with minimal value for dynamic comparison
normal_max_regid int Maximal value register identifier for dynamic comparison
normal_max_delta string Delta with maximal value for dynamic comparison
normal_min_val double Minimal value for standard comparison
normal_max_val double Maximal value for standard comparison
has_disabled int 1 = register has disabled state, 0 = register has no disabled state
disabled_regid int Comparative register identifier(for register of a bit type)
disabled_regid2 int Second comparative register identifier (for register of a bit type)
disabled_dynamic_value int 1 = compare register value with other register valueс, 0 = compare register value with constants
disabled_binary_value int Binary value (1 or 0) which turns on disabled register state
disabled_binary_text string Text to display disabled state
disabled_color string Disabled state color
disabled_min_regid int Minimal value register identifier for dynamic comparison
disabled_min_delta string Delta with minimal value for dynamic comparison
disabled_max_regid int Maximal value register identifier for dynamic comparison
disabled_max_delta string Delta with maximal value for dynamic comparison
disabled_min_val double Minimal value for standard comparison
disabled_max_val double Maximal value for standard comparison
has_warning int 1 = register has warning state, 0 = register has no warning state
warning_regid int Comparative register identifier (for register of a bit type)
warning_regid2 int Second comparative register identifier (for register of a bit type)
warning_dynamic_value int 1 = compare register value with other register's value, 0 = compare register value with constants
warning_binary_value int Binary value (1 or 0) which turns on warning state of the register
warning_binary_text string Text to display warning register state
warning_color string Warning state color
warning_min_regid int Minimal value register identifier for dynamic comparison
warning_min_delta string Delta with minimal value for dynamic comparison
warning_max_regid int Maximal value register identifier for dynamic comparison
warning_max_delta string Delta with maximal value for dynamic comparison
warning_min_val double Minimal value for standard comparison
warning_max_val double Maximal value for standard comparison
has_alert int 1 = register has alert state, 0 = register has no alert state
alert_regid int Comparative register identifier (for a bit type register)
alert_regid2 int Second comparative register (for a bit type register)
alert_dynamic_value int 1 = compare register value with other register's value, 0 = compare register value with constants
alert_binary_value int Binary value (1 or 0) which turns on alert state for the register
alert_binary_text string Text to display alert state
alert_color string Alert state color
alert_min_regid int Minimal value comparative register for dynamic comparison
alert_min_delta string Delta with minimal value for dynamic comparison
alert_max_regid int Maximal value comparative register for dynamic comparison
alert_max_delta string Delta with maximal value for dynamic comparison
alert_min_val double Minimal value for standard comparison
alert_max_val double Maximal value for standard comparison
timeformat string Date display format for registers of a UnixTime type
log_tolerance double Maximal change threshold when register value will be written to log
precision_digits int Number of digits after decimal point for fractional numbers
min_log_interval int Write value at least every X seconds
max_log_interval int Write value at most every X seconds
max_graph_interval int Connect points on graph curves if there is no data between them for more than X seconds
max_allowed_value double Maximal allowable value to enter for operator
min_allowed_value double Minimal allowable value to enter for operator
rw_mode string not used
min_reasonable_value double Minimal valid value. Dropping below this limit will force register value to nil.
max_reasonable_value double Maximal valid value. Raising above this limit will force register value to nil.
save_graph_data int Save date to draw grapsh.
graph_interval int time resolution for graph data. 0 = maximal resolution (assuming getting values from log), 1 = 1 minute, 2 = 2 minutes, 5 = 5 minutes, 15 = 15 minutes, 60 = 60 minutes
graph_color string Graph curve color
disabled int 0 = register is active, 1 = register is disabled
nocloud int 0 = send graph data to cloud , 1 = don't send grapsh data to cloud
delta int 0 = normal read mode, 1 = read the difference between current and previous values, 2 = same as “1” divided by time difference of these values (momentary speed)
delay int Poll rate in milliseconds. Can't be less than default value set in system settings. 0 = speed by default.
Data type identifiers:
0Bit
1Byte
2Word
3Double Word
4Unix Time
5String
Storage formats identifiers:
0Unsigned, Integer
1Signed, Integer
2Unsigned, Fixed Point Float (0 … +1)
3Signed, Fixed Point Float (-1 … +1)
4Two's complement
5Signed, Floating Point, 32 Bits, IEEE 754
6Signed, Floating Point, 24 Bits
7Signed, Floating Point, 32 Bits, IEEE 754, Reverse Word Order

Getting register log

To obtain entries from the register register, you must perform follwing GET request on a URL http://192.168.1.1/api/register-log.

In the request headers, it is necessary to pass the API key, the boundaries of the time interval of interest, and a list of register identifiers. X-WH-START and X-WH-END are transmitted in UnixTime format. The register ID is passed by a comma-separated list in the X-WH-REGISTERS header. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422595501
X-WH-END: 1422599101
X-WH-REGISTERS: 8,10

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported.

Accept: application/json
Content-Type: application/json

Example of querying records from the register log:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422595501
X-WH-END: 1422599101
X-WH-REGISTERS: 8,10

Reply example:

{
  "1422598266": [
    {
      "r": 8,
      "v": "6",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598271": [
    {
      "r": 8,
      "v": "11",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598276": [
    {
      "r": 8,
      "v": "16",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598280": [
    {
      "r": 8,
      "v": "0",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598285": [
    {
      "r": 8,
      "v": "5",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598290": [
    {
      "r": 8,
      "v": "10",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598295": [
    {
      "r": 8,
      "v": "15",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598300": [
    {
      "r": 8,
      "v": "0",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598305": [
    {
      "r": 8,
      "v": "5",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598310": [
    {
      "r": 8,
      "v": "10",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598315": [
    {
      "r": 8,
      "v": "15",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598320": [
    {
      "r": 8,
      "v": "0",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598325": [
    {
      "r": 8,
      "v": "5",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598330": [
    {
      "r": 8,
      "v": "10",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598335": [
    {
      "r": 8,
      "v": "15",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598340": [
    {
      "r": 8,
      "v": "0",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  "1422598345": [
    {
      "r": 8,
      "v": "5",
      "s": "-1"
    },
    {
      "r": 10,
      "v": "",
      "s": ""
    }
  ],
  и т.д.
]

Returns the array, where the index is time in UnixTime format. Elements of the array have another array of objects. Each object has three properties: r, v, s.

ris the register ID. For example, 10
vis the value of the register at the specified time point or an empty string if there is no data for this register at this time.
sis the state of the register that matched it at the specified time:
-1Unknown
0Disabled
1Normal
2Warning
3Alert
'' (an empty string)there is no register value.

Getting current registers values

To get a list of all registers, you must perform a GET request on the URL like this: http://192.168.1.1/api/registers.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

In the request headers, you must pass the connection IDs (IDs). Register values ​​will be returned only from those connections whose ID are specified in the X-WH-CONNECTIONS header. ID should be separated by comma, without spaces. This allows you to request not all registers, but only a part.

Example:

X-WH-CONNECTIONS: 1,2

In this example, register values for the ID=1 and ID=2 will be returned.

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of querying current register values:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-CONNECTIONS: 1,2

Example of the response:

{
  "1": {
    "r": "1",
    "v": "-1",
    "s": "i"
  },
  "2": {
    "r": "2",
    "v": "-1",
    "s": "i"
  },
  "3": {
    "r": "3",
    "v": "-1",
    "s": "i"
  },
  "4": {
    "r": "4",
    "v": "1422600498",
    "s": "u"
  },
  "5": {
    "r": "5",
    "v": "1422600498",
    "s": "u"
  },
  "6": {
    "r": "6",
    "v": "-1",
    "s": "i"
  },
  "7": {
    "r": "7",
    "v": "-1",
    "s": "i"
  },
  "8": {
    "r": "8",
    "v": "18",
    "s": "u"
  },
  "9": {
    "r": "9",
    "v": "0",
    "s": "u"
  }
}

The format of the returned data is as follows: Returns the object, where the property names are register IDs. And the properties themselves are yet another objects. Each object has three properties: r, v, s.

'r' is the register ID. For example, 10
'v' is the value of the register at the current time or '-1' if the value does not work.
's' is the state of the register that matched it at the specified time.
u Unknown
d Disabled
n Normal
w Warning
a Alert
i Incorrect

Writing a new value into a register

To write a new value into a register, it's neccessary to execute PUT-request on URL http://192.168.1.1/api/register-values/23. Here 23 - is the ID of the register to be modified.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

In the request body, the json-object with single property of “value” should be passed:

{"value":"12"}

Example of writing value of 15 to the register with ID = 5:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Request body:

{“value”:“15”}

If the request is valid, API will return HTTP-code 200.

List of dictionaries

To get a list of all connections, you must perform a GET request on the URL like this: http://192.168.1.1/api/connections.

To obtain information about a particular register, you must perform a following GET request on a URL 'http://192.168.1.1/api/registers/1' . Here “1” is the ID of the desired register.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of querying a list of all dictionaries:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

[
  {
    "id": "1",
    "title": "Рецепты",
    "value": "1,Green Tea<br>2,Black Tea<br>3,Lemon Grass"
  },
  {
    "id": "2",
    "title": "Режим подогрева",
    "value": "0,Выкл.<br>1,Вкл.<br>2,Авария"
  }
]

Example of querying information about the dictionary number 2:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "2",
  "title": "Режим подогрева",
  "value": "0,Выкл.<br>1,Вкл.<br>2,Авария"
}
Dictionary attributes:
id int Unique dictionary identifier
title string Dictionary name
value string Content of the dictionary. Dictionary records are divided with tag <br>. Each recored has a pair of key-value, separated with a comma. E.g.: 1,Green Tea. This means that when register value = 1 the following string will be displayed “Green Tea”

Trend list

To get a list of all registers, you must perform a GET request on the URL like this: http://192.168.1.1/api/registers.

To obtain information about a particular register, you must perform a following GET request on a URL 'http://192.168.1.1/api/registers/1' . Here “1” is the ID of the desired register.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of requesting a list of all trends:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response reply:

[
  {
    "id": "1",
    "regsid": "16",
    "title": "Горелка",
    "height": "350",
    "min_val": "0",
    "max_val": ""
  },
  {
    "id": "2",
    "regsid": "11,12,13",
    "title": "Токи A, B, C",
    "height": "350",
    "min_val": "0",
    "max_val": "1500"
  }
]

Example of requesting trend #2 information:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "2",
  "regsid": "11,12,13",
  "title": "Токи A, B, C",
  "height": "350",
  "min_val": "0",
  "max_val": "1500"
}
Trend attributes:
id int Unique trend identifier
title string Trend name
regsid string List of registers ids to be displayed on the trend.
height int Trend height in pixels
min_val double Minimal value of the Y axis
max_val double Maximal value of the Y axis

Graph list

To get a list of all graphs, you must perform a GET request on the URL like this: http://192.168.1.1/api/graphs.

To obtain information about a particular graph, you must perform a following GET request on a URL 'http://192.168.1.1/api/graphs/1' . Here “1” is the ID of the desired graph.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of query for the full graph list:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Reply example:

[
  {
    "id": "1",
    "regsid": "10,11",
    "title": "Горелка 1 и 2",
    "height": "350",
    "min_val": "0",
    "max_val": ""
  },
  {
    "id": "2",
    "regsid": "8",
    "title": "Температура в печи",
    "height": "350",
    "min_val": "0",
    "max_val": "200"
  }
]

Example of obtaining information about graph #2:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "2",
  "regsid": "8",
  "title": "Температура в печи",
  "height": "350",
  "min_val": "0",
  "max_val": "200"
}
Graph's attributes:
id int Unique graph identifier
title string Graph name
regsid string List of registers ids to be displayed on the graph.
height int Graph height in pixels
min_val double Minimal value of the Y axis
max_val double Maximal value of the Y axis

Alert list

To get a list of all alerts, you must perform a GET request on the URL like this: http://192.168.1.1/api/alerts.

To obtain information about a particular alert, you must perform a following GET request on a URL 'http://192.168.1.1/api/alerts/1' . Here “1” is the ID of the desired alert.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of query for the full graph list:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Reply example:

[
    {
        "id": "1",
        "title": "a1",
        "description": "<p>my alert</p>",
        "image": "",
        "level": "0",
        "sound": "0",
        "canack": "1",
        "dict_id": "",
        "condition": "[{\"condition\":\"moreThan\",\"regId\":1,\"min\":\"0\",\"max\":\"\",\"bitNum\":\"\",\"state\":\"\",\"value\":\"\"}]",
        "category": "",
        "group_id": ""
    },
    {
        "id": "2",
        "title": "a2",
        "description": "<p>my alert</p>",
        "image": "",
        "level": "0",
        "sound": "0",
        "canack": "1",
        "dict_id": "",
        "condition": "[{\"condition\":\"moreThan\",\"regId\":1,\"min\":\"0\",\"max\":\"\",\"bitNum\":\"\",\"state\":\"\",\"value\":\"\"}]",
        "category": "",
        "group_id": ""
    }
]

To get information about currently active alerts, you can use GetCurrentAlerts function and copying its output to some register (and then use GET method for current register's values).

Image list

To get a list of all images, you must perform a GET request on the URL like this: http://192.168.1.1/api/images.

To obtain information about a particular image, you must perform a GET request on a URL like this: 'http://192.168.1.1/api/images/1' . Here “1” is the ID of the desired connection.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of query for all images:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

[
  {
    "id": "1",
    "title": "Фон"
  },
  {
    "id": "2",
    "title": "Пламя"
  }
]

Example of querying information for image #2:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of reply:

Image attributes:
id int Unique image identifier
title string Image name

Getting graph data

To get data from graph log, it is necessary to run following GET-query for URL http://192.168.1.1/api/graph-data/2. Here 2 - is the ID of the graph of interest.

Also, instead of specifying the graph ID, you can send the X-WH-REGISTERS header. It specifies, through the comma, the ID of the registers for which data is to be extracted. Example:

X-WH-REGISTERS: 23,12,4

In the request headers, you must pass the API key, the boundaries of the time interval of interest (X-WH-START, X-WH-END) and the number of values ​​(X-WH-SLICES). X-WH-START and X-WH-END are transmitted in UnixTime format. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422797440
X-WH-END: 1422997405
X-WH-SLICES: 300

X-WH-SLICES is the number of values. The time interval X-WH-START-X-WH-END will be divided into X-WH-SLICES of equal intervals and the system will take the most detailed values ​​for each of them. X-WH-SLICES should be chosen based on the necessary detail of the graph. So, if you need to build a graph 800 pixels wide, then it makes no sense to choose more than 800 values ​​from the log. And sometimes there will be enough 200-400 values ​​depending on the width of the line on the graph.

To speed up the operation, the system can store the averaged values ​​of the registers for different intervals (1 minute, 2 minutes, 5 minutes, 15 minutes, 1 hour). In the configuration of each register, you can specify the required detail of the stored data. Depending on the selected time interval and the number of values, the system will attempt to take data from the most appropriate table of averaged values. or from the register register (if it is included for the specified register)

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of getting data for graph #1:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422854081
X-WH-END: 1422856235
X-WH-SLICES: 20

Response example:

[
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422861065000
  },
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422861173000
  },
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422861281000
  },
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422861388000
  },
  {
    "8": "0.000000;9.292714;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.674894;1.000000",
    "x": 1422861496000
  },
  {
    "8": "0.000000;9.489933;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.742101;1.000000",
    "x": 1422861604000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.747650;1.176471",
    "x": 1422861711000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.748471;1.176471",
    "x": 1422861819000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.746659;1.176701",
    "x": 1422861927000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.755068;1.176932",
    "x": 1422862034000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.741844;1.000000",
    "x": 1422862142000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.740291;1.000000",
    "x": 1422862250000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.756320;1.176701",
    "x": 1422862358000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.746004;1.176471",
    "x": 1422862465000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.754233;1.176932",
    "x": 1422862573000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.740343;1.000000",
    "x": 1422862681000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.751393;1.176932",
    "x": 1422862788000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.750868;1.176932",
    "x": 1422862896000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.745956;1.176701",
    "x": 1422863004000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.758306;1.176932",
    "x": 1422863111000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.741780;1.000000",
    "x": 1422863219000
  },
  {
    "8": "0.000000;9.500000;19.000000",
    "10": "NaN;NaN;NaN",
    "16": "0.000000;0.741780;1.000000",
    "x": 1422863327000
  },
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422863435000
  },
  {
    "8": "NaN;NaN;NaN",
    "10": "NaN;NaN;NaN",
    "16": "NaN;NaN;NaN",
    "x": 1422863542000
  }
]

The structure of the returned data is as follows. An array of objects is returned. Each object has an attribute 'x' - this is the timestamp of this entry. The time format is UnixTime multiplied by 1000 (the dimension is milliseconds). Also in this object there are attributes with values ​​for each register. The attribute name is the register ID. The attribute value is a string where the minimum, average and maximum value of the register on this interval is combined through a semicolon. For example, '0.000000; 0.755068; 1.176932' means that the register took values ​​from 0 to 1.176932, with its arithmetic mean being 0.755068. If in the given interval there is no data on the value of this register, the system will return 'NaN; NaN; NaN'.

Event list

To get the event list it is neccessary to execute GET-request to URL http://192.168.1.1/api/events.

To get data about specific event it is neccessary to execute GET-request to URL

http://192.168.1.1/api/events/1. Here “1” - is the event ID.

In the request headers, you must pass the API key, like this one:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of request for the event list:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

[
  {
    "id": "2",
    "title": "Интервал",
    "hasDuration": "1",
    "start": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"-499\" y=\"14\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"wh_reg\" id=\"3\"><field name=\"REG\">8</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"4\"><field name=\"NUM\">5</field></block></value></block></value></block></xml>",
    "end": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"-596\" y=\"16\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"wh_reg\" id=\"3\"><field name=\"REG\">8</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"4\"><field name=\"NUM\">10</field></block></value></block></value></block></xml>",
    "hasEndCondition": "1",
    "saveToLog": "1",
    "report_title": "Отчет \"интервал\"",
    "report_menu_title": "Интервал",
    "extra_regs": "-1^last^^Y-m-d H:i:s|2^last^^Y-m-d H:i:s",
    "color": "#ff0000",
    "savetologtype": "0",
    "loginterval": "",
    "parentid": "0",
    "showontimeline": "0",
    "description": ""
  },
  {
    "id": "3",
    "title": "Нажата кнопка А",
    "hasDuration": "1",
    "start": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"-613\" y=\"10\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"wh_reg\" id=\"4\"><field name=\"REG\">2</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"11\"><field name=\"NUM\">1</field></block></value></block></value></block></xml>",
    "end": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"10\" y=\"10\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field></block></value></block></xml>",
    "hasEndCondition": "0",
    "saveToLog": "1",
    "report_title": "Нажатие кнопки А",
    "report_menu_title": "Кнопка А",
    "extra_regs": "-1^last^^Y-m-d H:i:s|-2^last^^Y-m-d H:i:s",
    "color": "#0084ff",
    "savetologtype": "0",
    "loginterval": "",
    "parentid": "0",
    "showontimeline": "1",
    "description": "Событие срабатывает при нажатии на кнопку А"
  }
]

Example of request for the event #2 data:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "2",
  "title": "Интервал",
  "hasDuration": "1",
  "start": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"-499\" y=\"14\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"wh_reg\" id=\"3\"><field name=\"REG\">8</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"4\"><field name=\"NUM\">5</field></block></value></block></value></block></xml>",
  "end": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"wh_rules\" id=\"1\" inline=\"false\" deletable=\"false\" x=\"-596\" y=\"16\"><value name=\"IF\"><block type=\"logic_compare\" id=\"2\" inline=\"true\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"wh_reg\" id=\"3\"><field name=\"REG\">8</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"4\"><field name=\"NUM\">10</field></block></value></block></value></block></xml>",
  "hasEndCondition": "1",
  "saveToLog": "1",
  "report_title": "Отчет \"интервал\"",
  "report_menu_title": "Интервал",
  "extra_regs": "-1^last^^Y-m-d H:i:s|2^last^^Y-m-d H:i:s",
  "color": "#ff0000",
  "savetologtype": "0",
  "loginterval": "",
  "parentid": "0",
  "showontimeline": "0",
  "description": ""
}
Event addtributes:
id int unique event ID
title string event title
hasDuration string 0 = event triggers whenever condtition is met, 1 = event has duration in time
start string event start condition
end string event end condition
hasEndCondition int 0 = event has no end condition, 1 = event has end condition
saveToLog int 0 = don't save event to log, 1 = save event to log
report_title string event report title
report_menu_title string event report menu entry name
extra_regs string Extra registres to be saved in the event log
color string event color for the TimeLine
savetologtype int 0 = save data to log once, 1 = repetitive save to log each Х seconds
loginterval int log save period time , seconds
parentid int parent event ID. childe event may run only while parent event runs
showontimeline int 0 = don't show the event on the TimeLine, 1 = show event on the TimeLine
description string comments for the event (for operators and users of the system)

Getting data for events

To get data from event log, it is necessary to run following GET-query for URL http://192.168.1.1/api/event-data/2. Here 2 - is the ID of the graph of interest.

In the request headers, you must pass the API key and the boundaries of the time interval of interest. X-WH-START and X-WH-END are transmitted in UnixTime format. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422797440
X-WH-END: 1422997405

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Please refer for events chapter for more information.

Example of getting date about event #1:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422797440
X-WH-END: 1422997405

Example of response:

[
  {
    "rowid": "3050",
    "event_id": "1",
    "start_time": "1422797405",
    "end_time": "1422797440",
    "xtra_regs": [
      {
        "E1.0": 1422797405
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3052",
    "event_id": "1",
    "start_time": "1422797465",
    "end_time": "1422797500",
    "xtra_regs": [
      {
        "E1.0": 1422797465
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3054",
    "event_id": "1",
    "start_time": "1422797525",
    "end_time": "1422797560",
    "xtra_regs": [
      {
        "E1.0": 1422797525
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3056",
    "event_id": "1",
    "start_time": "1422797585",
    "end_time": "1422797680",
    "xtra_regs": [
      {
        "E1.0": 1422797585
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3058",
    "event_id": "1",
    "start_time": "1422797705",
    "end_time": "1422797740",
    "xtra_regs": [
      {
        "E1.0": 1422797705
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3060",
    "event_id": "1",
    "start_time": "1422797765",
    "end_time": "1422797800",
    "xtra_regs": [
      {
        "E1.0": 1422797765
      },
      {
        "E1.1": 39
      }
    ]
  },
  {
    "rowid": "3062",
    "event_id": "1",
    "start_time": "1422797825",
    "end_time": "0",
    "xtra_regs": [
      {
        "E1.0": 1422797825
      },
      {
        "E1.1": 39
      }
    ]
  }
]
Event's attrubutes:
rowid int Unique event identifier in database
event_id int Event ID
start_time int Event start time
end_time int Event end time. If the event still in progress, then end time = 0
xtra_regs object Object with data on additional registers which are saved in event log. Key - Value.

Additional register name format: “E” + event ID + “.” + register's serial number in the event starting from 0

Example of query for data on event #2:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422804505
X-WH-END: 1422800200

Response example:

[
  {
    "rowid": "3201",
    "event_id": "2",
    "start_time": "1422804505",
    "end_time": "1422804515",
    "xtra_regs": [
      {
        "E2.0": 25
      }
    ]
  },
  {
    "rowid": "3201",
    "event_id": "2",
    "start_time": "1422804505",
    "end_time": "1422804515",
    "xtra_regs": [
      {
        "E2.0": 27
      }
    ]
  },
  {
    "rowid": "3201",
    "event_id": "2",
    "start_time": "1422804505",
    "end_time": "1422804515",
    "xtra_regs": [
      {
        "E2.0": 29
      }
    ]
  },
  {
    "rowid": "3201",
    "event_id": "2",
    "start_time": "1422804505",
    "end_time": "1422804515",
    "xtra_regs": [
      {
        "E2.0": 31
      }
    ]
  },
  {
    "rowid": "3201",
    "event_id": "2",
    "start_time": "1422804505",
    "end_time": "1422804515",
    "xtra_regs": [
      {
        "E2.0": 33
      }
    ]
  }
]

Getting local time data

To get local time data, you must perform a GET request on the URL like this: http://192.168.1.1/api/timeinfo.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "timestamp": 1422861826,
  "timezone": "EET",
  "gmtoffset": 7200,
  "isdst": 0
}
Date and time attributes:
timestamp unixtime Current time in unixtime format
timezone string Time zone name
gmtoffset int Local time offset from UTC in seconds
isdst int 0 = winter time, 1 = summer time

Dashboard list

To get a list of all panels, you must perform a GET request on the URL like this: http://192.168.1.1/api/dashboards.

To obtain information about a particular dashboard, you must perform a following GET request on a URL 'http://192.168.1.1/api/graphs/12' . Here “12” is the ID of the desired graph.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

An example of querying a list of dashboards:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of response:

[
  {
    "id": "1",
    "title": "Упаковка",
    "hide_title": "0",
    "width": "900",
    "height": "450"
  },
  {
    "id": "2",
    "title": "Расход воды",
    "hide_title": "1",
    "width": "1024",
    "height": "800"
  }
]

Example of requesting information on dashboard number 1:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of reply:

{
  "id": "1",
  "title": "Упаковка",
  "hide_title": "0",
  "width": "900",
  "height": "450"
}
Dashboards attributes:
id int Unique dashboard identifier
title string Dashboard name
hide_title int 0 = display dashboard name , 1 = hide dashboard name
width int Working area width in pixels
height int Working area height in pixels

List of dashboard's blocks

To get a list of all dashboard's blocks, you must perform a GET request on the URL like this: http://192.168.1.1/api/blocks.

To obtain information about a particular block, you must perform a following GET request on a URL 'http://192.168.1.1/api/blocks/12' . Here “12” is the ID of the desired graph.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of a query for all blocks data:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Example of reply:

[
  {
    "id": "1",
    "dashboard_id": "1",
    "zindex": "1",
    "pos_left": "0",
    "pos_top": "0",
    "pos_width": "896",
    "pos_height": "445",
    "block_type": "Indicator",
    "title": "Фон",
    "url": "",
    "imageid": "1",
    "label": "",
    "align": "",
    "fontsize": "",
    "regid": "",
    "is_button": "false",
    "hide_value": "false",
    "start_value": "",
    "end_value": "",
    "colorize": "false"
  },
  {
    "id": "2",
    "dashboard_id": "1",
    "zindex": "3",
    "pos_left": "714",
    "pos_top": "277",
    "pos_width": "85",
    "pos_height": "25",
    "block_type": "TextValue",
    "title": "",
    "url": "",
    "imageid": "",
    "label": "",
    "align": "center",
    "fontsize": "4",
    "regid": "3",
    "is_button": "false",
    "hide_value": "false",
    "start_value": "",
    "end_value": "",
    "colorize": "false"
  },
  {
    "id": "3",
    "dashboard_id": "1",
    "zindex": "3",
    "pos_left": "450",
    "pos_top": "277",
    "pos_width": "110",
    "pos_height": "25",
    "block_type": "TextValue",
    "title": "",
    "url": "",
    "imageid": "",
    "label": "",
    "align": "left",
    "fontsize": "4",
    "regid": "5",
    "is_button": "",
    "hide_value": "",
    "start_value": "",
    "end_value": ""
  }
]

Example of query for block #1 information:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

{
  "id": "1",
  "dashboard_id": "1",
  "zindex": "1",
  "pos_left": "0",
  "pos_top": "0",
  "pos_width": "896",
  "pos_height": "445",
  "block_type": "Indicator",
  "title": "Фон",
  "url": "",
  "imageid": "1",
  "label": "",
  "align": "",
  "fontsize": "",
  "regid": "",
  "is_button": "false",
  "hide_value": "false",
  "start_value": "",
  "end_value": "",
  "colorize": "false"
}
Block attributes:
id int Unique block identifier
dashboard_id string Block dashboard-owner identifier where the block is displayed
zindex int Z-index of block (“layer” number)
pos_left int Position on the dashboards from left edge in pixels
pos_top int Position on the dashboards from top edge in pixels
pos_width int Block height in pixels
pos_height int Block width in pixels
block_type string Block type. Options: Indicator, TextValue, Gauge
title string Block name
url string URL for links
imageid int ID of the image to display
label string Text to be displayed in a block
align string Text alignment Options: left, right, center
fontsize int Font size, 1-5
regid int ID of the source register for value

Managing recipes list

To get a list of all recipes, you must perform a GET request on the URL like this: http://192.168.1.1/api/recipes.

To obtain information about a particular recipe, you must perform a following GET request on a URL 'http://192.168.1.1/api/recipes/12'. Here “12” is the ID of the desired recipe.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of a query for all recipes data:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Response example:

[
  {
    "id": "2",
    "title": "Black tea",
    "category": "",
    "description": "",
    "regs_values": "3^50|4^20|5^7",
    "allowed_for_roles": "1,2,3",
    "disabled": "0"
  },
  {
    "id": "1",
    "title": "Green tea",
    "category": "",
    "description": "",
    "regs_values": "3^100|4^10|5^5",
    "allowed_for_roles": "1,2,3",
    "disabled": "0"
  }
]
Block attributes:
id int Unique recipe identifier
title string Title of recipe
category string Category of recipe
description string Description of recipe
regs_values string List of register values in following format: reg_id1^new_value|reg_id2^new_value|reg_id3^new_value
allowed_for_roles string Comma-separated role IDs who can access this recipe
disabled int Flag that shows if recipe is disabled

To update a register values in particular recipe it's necessary to execute PUT-request on URL http://192.168.1.1/api/recipes/23. Here 23 - is the ID of the recipe to be modified.

In the headers, it is necessary to pass API key. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

In the request body, the json-object with at least of property be passed.

{"regs_values":"3^110|4^13|5^5","title": "Recipe for March 21st, 2019"}

Example of updating title and register values to the recipe with ID = 5:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7

Request body:

{“regs_values”:“3^110|4^13|5^5”, “title”: “Recipe for March 21st, 2019” }

If the request is valid, API will return HTTP-code 200.

Getting meters log

There is an option to use a register as a tolalizers for resources like water, has, heat, electricity etc. Then its current value together with hourly consumption will be stored in the database.

To obtain entries from the meters log, you must perform follwing GET request on a URL http://192.168.1.1/api/meters-log.

In the request headers, it is necessary to pass the API key, the boundaries of the time interval of interest, X-WH-START and X-WH-END are transmitted in UnixTime format. All meter registers will be returned, so X-WH-REGISTER header is omitted. For example:

X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422595501
X-WH-END: 1422599101

Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.

Accept: application/json
Content-Type: application/json

Example of querying records from the register log:

Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip, deflate, sdch
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
X-WH-START: 1422595501
X-WH-END: 1422599101

Reply example:

[
  {
    "t": 1586253600, // timestamp 
    "r": 65,         // register id 
    "s": "0.0",      // hour start value 
    "e": "5.0",      // hour end value
    "v": "5.0"       // difference
  },
  {
    "t": 1586257200, 
    "r": 65,
    "s": "5.0",
    "e": "20.0",
    "v": "15.0"
  },
  {
    "t": 1586257200,
    "r": 76,
    "s": "100.0",
    "e": "200.0",
    "v": "100.0"
  }
]

The // are comments, they are absent in the real reponse.

API usage examples

access_via_api.txt · Last modified: 2023/03/02 10:53 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki