API - List of dashboard's blocks
Материал из WebHMI Wiki
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:
URL: http://192.168.1.1/api/blocks
Method: GET
Headers:
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:
URL: http://192.168.1.1/api/blocks/1
Method: GET
Headers:
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 |
is_button | int | 0 = user can change value, 1 = user can not change value |
hide_value | int | 0 = display numeric value, 1 = don't display numeric value |
start_value | double | Start point value for Gauge block |
end_value | double | End point value for Gauge block |
colorize | int | 0 = display block in black color, 1 = colrize block according to register's state |