# HTTP API
# Introduction
Most of the functions provided by CLTPlatform are implemented through HTTP API.
At present, there are three kinds of HTTP APIs for a functional:
Detect
API to update information from the device.Such interfaces generally start with
/detect...
. For example:Detect device general information:
/v2/device/detectNormalInfo
Get
APISuch interfaces generally start with
/get...
. For example:Get device general information:
/v2/device/getNormalInfo
Set
APISuch interfaces generally start with
/Set...
. For example:Set device general information:
/v2/device/setDeviceName
# API Format
{URI-scheme}://{endpoint}/{api_version}/{module}/{resouce_path}?{query_string}
symbol | explain |
---|---|
URI-scheme | Using http |
endpoint | service domain or ip : port number |
api_version | api version number, used to manage api versions |
module | module path |
resource_path | resource path |
query_string | query parameter, not require |
# Request Method
The following request methods are supported.
POST
The Content-Type
of the request should be application/json
.
TIP
In the interface design, all functional requests are implemented through POST
.
# Request Parameter
GET
: Parameter in queryPOST
:The parameter is in the body, in json format.The parameters of the 'POST' request are fixed in the following format, where
data
indicates the parameters of the request, andcommand
indicates the type of the request, which is generally the same as the request url.{ "command": "request type", "data": { "param1": "parameter1", "param2": "parameter2" } }
For example, the request for general device information
/v2/device/getNormalInfo
has the following parameters:{ "command": "/v2/device/getNormalInfo", "data": { "deviceIndex": 0 } }
# Response
The parameters of the response are fixed in the following format, where data
indicates the data of the request, which is returned when the device information is requested. command
indicates the type of instruction requested, ibid. code
and message
indicates the result of the request.
{
"command": "Request type",
"code": "Error code",
"message": "Message",
"data": {
"data1": "",
"data2": ""
}
}
# Error Code
See the API error description for details.