News&Events
About
API Ref
API Directory
UserManual
nodeMCU
python
PC Software
EnergyMeter
WiFi HT
downloads

reference

General Information


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).


Authentication


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:


API Usage


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.
 

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: 

gateway/updateSensors

Upload sensor data

URL

http://en.DeviceBit50.com/api/v1/gateway/UpdateSensors/{device no}

Need Userkey

Yes

URL request parameters

None

HTTP request type

POST

Post data example

[    {        "Name":"T1",        "Value":"1"    },    {        "Name":"01H1",        "Value":"96.2"    }]

Post data format

  Required Type Remark
Name Yes string Sensor ID
Value Yes string Sensor value

Return format

JSON

Return example

{    "Successful": true,     "Message": null}

Return fields

Name Type Remark
Successful boolean Successful
Message string Message if error

Remark

Online test tools

API online test

 

 

 

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.