A hierarchy of data types is used to represent data in the Lewei Platform, i.e. user-device-sensor. DeviceBit platform provides most of its Internet of Things (IOT) functionality, such as “Update sensor data” or “Get sensor data”, via its Application Programming Interface (API).
The system allocates each account a user key after signing up. User keys are used to control access to the resources via the API. The user key must be included in Http header. An example using Curl is:
curl -request POST --data [{"Name":"T1","Value":“23"}] --header "userkey: 84xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx“ http://open.DeviceBit50.com/api/V1/Gateway/UpdateSensors/01
Log into DeviceBit system and go to “My account”-“Personal settings” to query the user key, shown as below:
1. There are two requests of HTTP type: Post and Get. “Simply add parameters in the request URL for “Get” method. For “Post” method, the sent data format must be set as DeviceBit definition. An example using Curl is: -request POST --data [{"Name":"T1","Value":“23"}]
2. The format of return data is Json. The definition of field refers to below API instruction.
There are three different types of API. The user can find the specified API in API document by index for different types. Each API includes the below information:
Upload sensor data
http://en.DeviceBit50.com/api/v1/gateway/UpdateSensors/{device no}
Yes
None
POST
[ { "Name":"T1", "Value":"1" }, { "Name":"01H1", "Value":"96.2" }]
Required | Type | Remark | |
---|---|---|---|
Name | Yes | string | Sensor ID |
Value | Yes | string | Sensor value |
JSON
{ "Successful": true, "Message": null}
Name | Type | Remark |
---|---|---|
Successful | boolean | Successful |
Message | string | Message if error |
DeviceBit platform provides API online test tool. The user click the link of online test tool introduced above to browse the test webpage, as shown below:
Note that: Replace the device ID according to your actual device configuration in DeviceBit platform in URL (http://www.DeviceBit50.com/api/V1/gateway/UpdateSensors/{device ID}).
On the right of the webpage, the Request and Respond data are displayed during test, which is for reference.