access_via_api
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
access_via_api [2020/04/07 10:05] – [Getting graph data] emozolyak | access_via_api [2020/04/07 10:08] – [Getting register log] emozolyak | ||
---|---|---|---|
Line 874: | Line 874: | ||
| 3|Alert | | | 3|Alert | | ||
| '' | | '' | ||
+ | |||
+ | ===== Getting meters log ===== | ||
+ | |||
+ | To obtain entries from the register register, you must perform follwing GET request on a URL http:// | ||
+ | |||
+ | 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: | ||
+ | X-WH-START: 1422595501 | ||
+ | X-WH-END: 1422599101 | ||
+ | X-WH-REGISTERS: | ||
+ | | ||
+ | Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported. | ||
+ | |||
+ | Accept: application/ | ||
+ | Content-Type: | ||
+ | |||
+ | Example of querying records from the meters log: | ||
+ | |||
+ | ***URL**: http:// | ||
+ | ***Method**: | ||
+ | *Header: | ||
+ | |||
+ | Accept: application/ | ||
+ | Content-Type: | ||
+ | Accept-Encoding: | ||
+ | X-WH-APIKEY: | ||
+ | X-WH-START: 1422595501 | ||
+ | X-WH-END: 1422599101 | ||
+ | X-WH-REGISTERS: | ||
+ | |||
+ | Reply example: | ||
+ | |||
+ | < | ||
+ | { | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | и т.д. | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | 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. | ||
+ | |||
+ | ^r|is the register ID. For example, 10 | | ||
+ | ^v|is 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. | | ||
+ | ^s|is the state of the register that matched it at the specified time: | | ||
+ | | -1|Unknown | | ||
+ | | 0|Disabled | | ||
+ | | 1|Normal | | ||
+ | | 2|Warning | | ||
+ | | 3|Alert | | ||
+ | | '' | ||
+ | |||
===== Getting current registers values ===== | ===== Getting current registers values ===== | ||
Line 1296: | Line 1552: | ||
|title |string |Image name| | |title |string |Image name| | ||
- | ===== Getting | + | ===== Getting |
- | There is an option | + | To get data from graph log, it is necessary |
- | To obtain entries from the meters, you must perform follwing GET request on a URL | + | Also, instead of specifying |
- | http://192.168.1.1/ | + | |
- | In the request headers, | + | X-WH-REGISTERS: |
+ | |||
+ | In the request headers, | ||
X-WH-APIKEY: | X-WH-APIKEY: | ||
- | X-WH-START: | + | X-WH-START: |
- | X-WH-END: | + | X-WH-END: |
- | X-WH-REGISTERS: 8,10 ?? check this | + | X-WH-SLICES: 300 |
- | + | ||
- | Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat | + | 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 | ||
Accept: application/ | Accept: application/ | ||
Content-Type: | Content-Type: | ||
+ | | ||
+ | Example of getting data for graph #1: | ||
- | Example of querying records from the register log: | + | |
- | + | ***Method:** GET | |
- | | + | *Headers: |
- | ***Method**: GET | + | |
- | *Header: | + | |
Accept: application/ | Accept: application/ | ||
Line 1325: | Line 1587: | ||
Accept-Encoding: | Accept-Encoding: | ||
X-WH-APIKEY: | X-WH-APIKEY: | ||
- | X-WH-START: | + | X-WH-START: |
- | X-WH-END: | + | X-WH-END: |
- | X-WH-REGISTERS: 8,10 | + | X-WH-SLICES: 20 |
- | + | ||
- | Reply example: | + | |
+ | Response example: | ||
< | < | ||
- | { | + | [ |
- | "1422598266": | + | |
- | | + | |
- | | + | "10": |
- | "v": "6", | + | "16": "NaN;NaN;NaN", |
- | "s": | + | "x": |
- | }, | + | }, |
- | { | + | { |
- | "r": | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "NaN;NaN;NaN", |
- | | + | |
- | | + | |
- | | + | |
- | | + | " |
- | | + | "10": "NaN;NaN;NaN", |
- | "v": "11", | + | "16": "NaN;NaN;NaN", |
- | "s": "-1" | + | "x": |
- | }, | + | }, |
- | | + | { |
- | | + | " |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": | + | "16": "NaN;NaN;NaN", |
- | } | + | "x": |
- | ], | + | }, |
- | | + | |
- | | + | " |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "16", | + | "16": "0.000000; |
- | "s": "-1" | + | "x": |
- | }, | + | }, |
- | | + | |
- | | + | "8": "0.000000; |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": | + | "16": "0.000000; |
- | } | + | |
- | ], | + | |
- | | + | { |
- | | + | "8": |
- | | + | "10": "NaN;NaN;NaN", |
- | "v": " | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | { |
- | | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": | + | "16": "0.000000; |
- | } | + | |
- | | + | |
- | "1422598285": | + | { |
- | { | + | "8": |
- | | + | "10": "NaN;NaN;NaN", |
- | "v": "5", | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | { | + | { |
- | "r": | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | |
- | | + | |
- | | + | { |
- | | + | "8": |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "10", | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | { | + | |
- | "r": | + | " |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | "x": |
- | | + | |
- | | + | { |
- | | + | "8": |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "15", | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | { | + | { |
- | "r": | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | |
- | | + | |
- | | + | { |
- | | + | "8": |
- | "r": 8, | + | "10": "NaN;NaN;NaN", |
- | "v": " | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | { |
- | | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": | + | "16": "0.000000; |
- | } | + | |
- | | + | |
- | | + | { |
- | | + | "8": |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "5", | + | "16": "0.000000; |
- | "s": "-1" | + | |
- | }, | + | |
- | { | + | { |
- | "r": | + | "8": |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | |
- | | + | |
- | | + | |
- | | + | " |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "10", | + | "16": "0.000000; |
- | "s": "-1" | + | "x": |
- | }, | + | }, |
- | { | + | |
- | "r": | + | " |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | "x": |
- | | + | }, |
- | | + | |
- | | + | " |
- | "r": | + | "10": "NaN;NaN;NaN", |
- | "v": "15", | + | "16": "0.000000; |
- | "s": "-1" | + | "x": |
- | }, | + | }, |
- | { | + | |
- | "r": | + | " |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": "" | + | "16": "0.000000; |
- | | + | "x": |
- | | + | }, |
- | | + | |
- | | + | " |
- | | + | "10": "NaN;NaN;NaN", |
- | "v": " | + | "16": "NaN;NaN;NaN", |
- | "s": "-1" | + | "x": |
- | }, | + | }, |
- | | + | |
- | | + | " |
- | "v": "", | + | "10": "NaN;NaN;NaN", |
- | "s": | + | "16": "NaN;NaN;NaN", |
- | } | + | "x": |
- | ], | + | } |
- | | + | |
- | | + | |
- | | + | |
- | "v": "5", | + | |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "v": "", | + | |
- | "s": | + | |
- | } | + | |
- | ], | + | |
- | | + | |
- | | + | |
- | | + | |
- | "v": "10", | + | |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "v": "", | + | |
- | "s": | + | |
- | } | + | |
- | ], | + | |
- | | + | |
- | | + | |
- | | + | |
- | "v": "15", | + | |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "v": "", | + | |
- | "s": | + | |
- | } | + | |
- | ], | + | |
- | | + | |
- | | + | |
- | | + | |
- | "v": "0", | + | |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "v": "", | + | |
- | "s": | + | |
- | } | + | |
- | ], | + | |
- | | + | |
- | | + | |
- | | + | |
- | "v": "5", | + | |
- | "s": "-1" | + | |
- | }, | + | |
- | | + | |
- | | + | |
- | "v": "", | + | |
- | "s": | + | |
- | } | + | |
- | ], | + | |
- | и т.д. | + | |
] | ] | ||
</ | </ | ||
- | Returns | + | The structure of the returned data is as follows. An array of objects |
- | Each object has three properties: r, v, s. | + | 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 |
- | + | ||
- | ^r|is the register ID. For example, 10 | | + | |
- | ^v|is the value of the register | + | |
- | ^s|is the state of the register | + | |
- | | -1|Unknown | | + | |
- | | 0|Disabled | | + | |
- | | 1|Normal | | + | |
- | | 2|Warning | | + | |
- | | 3|Alert | | + | |
- | | '' | + | |
===== Event list ===== | ===== Event list ===== |
access_via_api.txt · Last modified: 2023/03/02 10:53 by emozolyak