API - Список словарей/en — различия между версиями

Материал из WebHMI Wiki
Перейти к: навигация, поиск
(Новая страница: «Dictionary attributes:»)
(Новая страница: «<table> <tr><td>'''id'''</td><td>int</td><td>Unique dictionary identifier</td></tr> <tr><td>'''title'''</td><td>string</td><td>Dictionary name</td></tr> <tr><td>'…»)
 
Строка 75: Строка 75:
  
 
<table>
 
<table>
<tr><td>'''id'''</td><td>int</td><td>Уникальный идентификатор словаря</td></tr>
+
<tr><td>'''id'''</td><td>int</td><td>Unique dictionary identifier</td></tr>
<tr><td>'''title'''</td><td>string</td><td>Название словаря</td></tr>
+
<tr><td>'''title'''</td><td>string</td><td>Dictionary name</td></tr>
<tr><td>'''value'''</td><td>string</td><td>Содержание словаря. Записи словаря разделены тегом &lt;br&gt;. Каждая запись содержит пару ключ-значение разделенные запятой. Например: 1,Green Tea. Это значит что при значении регистра = 1 будет отображаться строка "Green Tea"</td></tr>
+
<tr><td>'''value'''</td><td>string</td><td>Content of the dictionary. Dictionary records are divided with tag &lt;br&gt;. 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"</td></tr>
 
</table>
 
</table>

Текущая версия на 14:11, 13 апреля 2018

Другие языки:
English • ‎русский

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:

URL: http://192.168.1.1/api/dictionaries
Method: GET

Headers:

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:

URL: http://192.168.1.1/api/dictionaries
Method: GET

Headers:

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:

idintUnique dictionary identifier
titlestringDictionary name
valuestringContent 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"