User Tools

Site Tools


access_via_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
access_via_api [2018/12/11 12:07] – [Getting current registers values] emozolyakaccess_via_api [2019/06/07 14:29] akuzmuk
Line 624: Line 624:
 To obtain entries from the register register, you must perform follwing GET request on a URL http://192.168.1.1/api/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-REG-IDS header. For example:+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-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
   X-WH-START: 1422595501   X-WH-START: 1422595501
   X-WH-END: 1422599101   X-WH-END: 1422599101
-  X-WH-REG-IDS: 8,10+  X-WH-REGISTERS: 8,10
      
 Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported. Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported.
Line 648: Line 648:
   X-WH-START: 1422595501   X-WH-START: 1422595501
   X-WH-END: 1422599101   X-WH-END: 1422599101
-  X-WH-REG-IDS: 8,10+  X-WH-REGISTERS: 8,10
  
 Reply example: Reply example:
Line 883: Line 883:
   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7   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-CONNS header. ID should be separated by comma, without spaces. This allows you to request not all registers, but only a part.+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: Example:
  
-  X-WH-CONNS: 1,2+  X-WH-CONNECTIONS: 1,2
      
 In this example, register values for the ID=1 and ID=2 will be returned. In this example, register values for the ID=1 and ID=2 will be returned.
Line 906: Line 906:
   Accept-Encoding: gzip, deflate, sdch   Accept-Encoding: gzip, deflate, sdch
   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
-  X-WH-CONNS: 1,2+  X-WH-CONNECTIONS: 1,2
      
 Example of the response: Example of the response:
Line 1300: Line 1300:
 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. 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-REGS header. It specifies, through the comma, the ID of the registers for which data is to be extracted. Example:+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-REGS: 23,12,4+  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: 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:
Line 2107: Line 2107:
 |**regid**| int |ID of the source register for value | |**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:
 +
 +  ***URL:** http://192.168.1.1/api/recipes
 +  ***Method:** GET
 +  *Headers:
 +
 +  Accept: application/json
 +  Content-Type: application/json
 +  Accept-Encoding: gzip, deflate, sdch
 +  X-WH-APIKEY:F3C74230818DA487BB2017CE5D0290F4DABCAFD7
 +
 +Response example:
 +<code>
 +[
 +  {
 +    "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"
 +  }
 +]
 +</code>
 +
 +^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 [[https://ru.wikipedia.org/wiki/JSON |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.
 +<code>
 +{"regs_values":"3^110|4^13|5^5","title": "Recipe for March 21st, 2019"}
 +</code>
 +
 +Example of updating title and register values to the recipe with ID = 5:
 +
 +  ***URL**: http://192.168.1.1/api/recipe/5
 +  ***Method**: PUT
 +  *Headers:
 +
 +  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.
  
access_via_api.txt · Last modified: 2023/03/02 10:53 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki