Documentation
|
To protect data from third parties access rights will be queried by comparing keys. To read and edit data different keys are needed. Therefore a read key (ApiRdKey) to read data and a write key (ApiWrKey) to write data is used. This is shown in lisitng.
Serveral security levels are implemented, so that not every user has access to all data, if one key is known. This means, it's possible that multiple keys are needed for different data. This keys can be changed anytime by authorised personal.
In order to read data from the device, an HTTP GET request at the desired API path has to be made. Its possible to read the whole json structure of one endpoint, as well as a part or just one variable of the endpoint with one request. Reading multiple endpoints with one request is not supported. The listing shows the general structure of a read request. A request with the command-line application "cURL" generates the shown HTTP-request. For example the response of a request to the URI http://192.168.15.100/api/v1/properties/name is only the name of the device. However, if the URI is http://192.168.15.100/api/v1/properties all device settings are received.
For editing data the HTTP PUT-method has to be used. Multiple values can only be changed, if they are in the same object. For example: setting the IP address and IP mask simultanously is possible, since they are in the same object. but setting the IP address and enabling SNTP client (setting the enable variable to true) is not possible since they are in different objects in the json structure.
The data must be added as content (http message body data) to the PUT request, encoded with the application/x-www-form-urlencoded MIME type. With the cURL command an HTTP request, as shown below, is generated.
A request on a valid REST API endpoint has always the HTTP response status 200 - OK., even if the path doesn't exist (e.g. /api/v1/data/test). Requests on a non existing REST API endpoint (e.g. /api/v1/test) will have the HTTP response status 404 - Not Found.
For a list of valid paths see Structure of Endpoints
The response on valid REST API paths is a JSON object containing two variables. The first ("meta") holds the information about the success of the request. The second ("data") holds the data in case of an read request.
This request is valid, since meta holds the error code 0 and respectively the message "JSON_ERROR_NONE" In this case we requested a specific variable, which is of type float (/api/v1/data/entries/0/pin) so the data variable holds a float value.
This request is valid, since meta holds the error code 0 and respectively the error message "JSON_ERROR_NONE" In this case we made a request to an object (/api/v1/data/entries/0) so the data variable holds an object.
In this case we made a request to a non existing object (/api/v1/data/test) so the meta variable hold the error code 6 and the corresponding error message. In this case the data object/value is empty or null. It should not be interpreted in any way.
The server's response always contains one of these API status codes and the corresponding status message.
status code | status message | description |
---|---|---|
0 | JSON_ERROR_NONE | No error |
1 | JSON_ERROR_MEMORY_ALLOCATION | Not enough memory space could be reserved. |
2 | JSON_ERROR_MEMORY_TOKEN_NOT_FOUND | The token could not be found within a specific memory. |
3 | JSON_ERROR_UNKNOWN_HANDLE | The used handle is unknown. |
4 | JSON_ERROR_APIRDKEY | Wrong or missing ApiRdKey |
5 | JSON_ERROR_APIWRKEY | Wrong or missing ApiWrKey |
6 | JSON_ERROR_TOKEN_NOT_FOUND | The value to be edited could not be found. |
7 | JSON_ERROR_TOKEN_CHANGEFXN_NOT_FOUND | The function to edit a value is not implemented or the designation is incorrect. |
8 | JSON_ERROR_TOKEN_CHANGEFXN_NOT_ALLOWED | It's not allowed to change the selected value. |
9 | JSON_ERROR_TOKEN_CHANGEFXN_FAILED | Failed to change a value. |
10 | JSON_ERROR_SAVEFXN_FAILED | Failed to save a value. |
11 | JSON_ERROR_TYPE_OBJECT | No JSON object was used. |
12 | JSON_ERROR_TYPE_INTEGER | Provided value is not an Integer. |
13 | JSON_ERROR_TYPE_INTEGER_MINIMUM | Provided integer value is smaller than allowed. |
14 | JSON_ERROR_TYPE_INTEGER_MAXIMUM | Provided integer value is bigger than allowed. |
15 | JSON_ERROR_TYPE_INTEGER_UNSIGNED | Provided value is not an unsigned Integer. |
16 | JSON_ERROR_TYPE_STRING | Provided value is not a String. |
17 | JSON_ERROR_TYPE_STRING_LENGTH | Provided string is too long. |
18 | JSON_ERROR_TYPE_BOOLEAN | Provided value is not a Boolean. |
19 | JSON_ERROR_TYPE_DOUBLE | Provided value is not a Double. |
20 | JSON_ERROR_OBJECT_TYPENAME | The requested class doesn't exist. |
21 | JSON_ERROR_OBJECT_TYPEREVISION | The revision of the class is wrong. |
22 | JSON_ERROR_COUNT | Other Error |