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

Материал из WebHMI Wiki
Перейти к: навигация, поиск
(Новая страница: «Also, in the headers, you must specify the desired data exchange format. Currently, only the [https://en.wikipedia.org/wiki/JSON JSON] format is supported. <pre>…»)
(Новая страница: «<table> <tr><td>'''id'''</td><td>int</td><td>Unique trend identifier</td></tr> <tr><td>'''title'''</td><td>string</td><td>Trend name</td></tr> <tr><td>'''regsid''…»)
 
(не показано 7 промежуточных версий этого же участника)
Строка 16: Строка 16:
  
  
Пример запроса списка всех трендов:
+
Example of requesting a list of all trends:
  
 
'''URL''': http://192.168.1.1/api/trends<br>
 
'''URL''': http://192.168.1.1/api/trends<br>
 
'''Method''': GET
 
'''Method''': GET
  
Заголовки:
+
Headers:
 
<pre>
 
<pre>
 
Accept: application/json
 
Accept: application/json
Строка 29: Строка 29:
 
</pre>
 
</pre>
  
Пример ответа:
+
Response reply:
 
<pre>
 
<pre>
 
[
 
[
Строка 53: Строка 53:
  
  
Пример запроса информации о тренде номер 2:
+
Example of requesting trend #2 information:
  
 
'''URL''': http://192.168.1.1/api/trends/2<br>
 
'''URL''': http://192.168.1.1/api/trends/2<br>
 
'''Method''': GET
 
'''Method''': GET
  
Заголовки:
+
Headers:
 
<pre>
 
<pre>
 
Accept: application/json
 
Accept: application/json
Строка 66: Строка 66:
 
</pre>
 
</pre>
  
Пример ответа:
+
Response example:
 
<pre>
 
<pre>
 
{
 
{
Строка 80: Строка 80:
  
  
Атрибуты тренда:
+
Trend attributes:
  
 
<table>
 
<table>
<tr><td>'''id'''</td><td>int</td><td>Уникальный идентификатор тренда</td></tr>
+
<tr><td>'''id'''</td><td>int</td><td>Unique trend identifier</td></tr>
<tr><td>'''title'''</td><td>string</td><td>Название тренда</td></tr>
+
<tr><td>'''title'''</td><td>string</td><td>Trend name</td></tr>
<tr><td>'''regsid'''</td><td>string</td><td>Список идентификаторов регистров которые необходимо отображать на тренде. Регистры разделены запятыми.</td></tr>
+
<tr><td>'''regsid'''</td><td>string</td><td> List of registers ids to be displayed on the trend.</td></tr>
<tr><td>'''height'''</td><td>int</td><td>Высота тренда в пикселях</td></tr>
+
<tr><td>'''height'''</td><td>int</td><td>Trend height in pixels</td></tr>
<tr><td>'''min_val'''</td><td>double</td><td>Минимальное значение оси Y</td></tr>
+
<tr><td>'''min_val'''</td><td>double</td><td>Minimal value of the Y axis</td></tr>
<tr><td>'''max_val'''</td><td>double</td><td>Максимальное значение оси Y</td></tr>
+
<tr><td>'''max_val'''</td><td>double</td><td>Maximal value of the Y axis</td></tr>
 
</table>
 
</table>

Текущая версия на 07:33, 16 апреля 2018

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:

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

Headers:

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:

URL: http://192.168.1.1/api/trends/2
Method: GET

Headers:

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:

idintUnique trend identifier
titlestringTrend name
regsidstring List of registers ids to be displayed on the trend.
heightintTrend height in pixels
min_valdoubleMinimal value of the Y axis
max_valdoubleMaximal value of the Y axis