Skip to main content

ThingsIoT Platform API Documentation

1. Login API

  • URL
    http://things-api.iotddc.com/edge-user/user/apiLogin
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
usernameStringYqueryNonetest
passwordStringYqueryNone123456
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjecttokenAccess token
roleIdAccount type: 1 = primary account; 2 = sub-account
projectIdProject ID. When roleId is 2, the ID of the assigned project is returned. When roleId is 1, select a project from the project list.
  • Primary-account login example
  • Sub-account login example

2. Get the Project List

  • URL
    http://things-api.iotddc.com/edge-user/project/list
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
pageIntYquery1Current page
sizeIntYquery10Number of records per page
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectlistProject list
totalPageTotal number of pages
totalRowTotal number of records
pageNumberCurrent page
pageSizeNumber of records per page
  • Primary-account project-list example

3. Get Data Points

Get Data Points as a List

  • URL
    http://things-api.iotddc.com/edge-data/data/tags
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
projectIdintYqueryNoneProject ID
pageintYquery1Current page
sizeintYquery10Number of records per page
snStringNqueryNoneGateway SN
realBooleanNqueryNoneWhether to include real-time data
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectlistData-point list
totalPageTotal number of pages
totalRowTotal number of records
pageNumberCurrent page
pageSizeNumber of records per page
  • Query parameter description: sn and real are optional filter conditions.
  • Request example

Get Data Points as a Tree

Query by Project

  • URL
    http://things-api.iotddc.com/edge-data/data/getTagsTree
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
projectIdraw.jsonYbodyNoneProject ID
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectData-node tree
nameName of the current node. The root node is the gateway.
childrenChild nodes. Second-level nodes are devices, and leaf nodes are data points.
  • Request example

Query by Gateway

  • URL
    http://things-api.iotddc.com/edge-data/data/getTagsTreeByGateway
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
gatewayIdraw.jsonYbodyNoneGateway SN or gateway ID
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectData-node tree
nameName of the current node. The root node is the gateway.
childrenChild nodes. Second-level nodes are devices, and leaf nodes are data points.

4. Subscribe to Real-Time Data

  • Real-time data is subscribed to and pushed through WebSocket.

WebSocket Connection

  • URL: ws://things-api.iotddc.com/edge-data/ws/scada/sub
  • Example
const url = "ws://things-api.iotddc.com/edge-data/ws/real/sub"
let socket = new WebSocket(url)
socket.onopen = function() {
console.log("ws open")
}

Send the Data Points to Subscribe To

  • After the WebSocket connection is established:
socket.onopen = function () {
console.log("ws open")
// TODO: Send the subscription request in the following format.
// Multiple data points can be specified, or all data points can be subscribed to.
data = {
"type": "read",
"projectId": "44", // Project ID
"ids": [
"240117502.Device2.tag0001", // Data-point ID. ".*" subscribes to all points in the project.
// You can also subscribe by prefix, such as "240117502."
// or "240117502.Device2."
"240117502.Device2.tag0002"
]
}
}

Receive Real-Time Data

  • Code example
socket.onmessage = function (evnet) {
console.log(evnet.data)
}
  • Response example
{
"code": 200,
"data": [
{
"val": 37,
"id": "240117502.Device2.tag0001",
"timestamp": 1714286290,
"status": "Good"
},
{
"val": 71,
"id": "240117502.Device2.tag0002",
"timestamp": 1714286290,
"status": "Good"
}
],
"message": "success"
}

5. Query Historical Data

Raw Data Query

  • URL
    http://things-api.iotddc.com/edge-data/data/history
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
projectIdIntYbody(raw.json)NoneProject ID
idStringYbody(raw.json)NoneData-point ID
startTimeStringYbody(raw.json)NoneStart time in yyyy-MM-dd HH:mm:ss format
endTimeStringYbody(raw.json)NoneEnd time in yyyy-MM-dd HH:mm:ss format
pageIntYbody(raw.json)1Current page
sizeIntYbody(raw.json)10Number of records per page
  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectlistData list
totalPageTotal number of pages
totalRowTotal number of records
pageNumberCurrent page
pageSizeNumber of records per page
  • Raw data query example

Aggregated Data Query

  • URL
    http://things-api.iotddc.com/edge-data/data/aggQueryHistory
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
projectIdIntYbody(raw.json)NoneProject ID
idsListYbody(raw.json)NoneList of data-point IDs
startTimeStringYbody(raw.json)NoneStart time in yyyy-MM-dd HH:mm:ss format
endTimeStringYbody(raw.json)NoneEnd time in yyyy-MM-dd HH:mm:ss format
countIntYbody(raw.json)1Aggregation interval
aggTypeStringYbody(raw.json)10Aggregation method
  • Aggregation Description
    Used to reduce the number of samples.
    The minimum time window is 1m.
    Supported aggregation methods within each time window are first, last, min, max, sum, mean (average), and median.

  • Response Parameters

ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectlistData list
totalPageTotal number of pages
totalRowTotal number of records
pageNumberCurrent page
pageSizeNumber of records per page
  • Aggregated data query example

6. Query Home-Page Data

  • URL
    http://things-api.iotddc.com/edge-data/data/
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
projectIdIntYbodyNoneProject ID
dayIntYbody7Query time range
  • Query Time-Range Description
    This parameter is used only to limit the time range of daily statistical messages.

  • Response Parameters

ParameterTypeFieldDescription
codeIntError code
messageStringError message
dataJSONObjectgatewayNumber of gateways
deviceNumber of devices
tagNumber of data points
alarmNumber of alarms
writeLogNumber of write commands issued
messageDaily message-volume statistics
alertCountDaily alarm-count statistics
logDaily write-command-volume statistics
  • Home-page data query example

7. Issue a Control Command

  • URL
    http://things-api.iotddc.com/edge-data/data/writeTag
  • Request Method
    post
  • Request Parameters
ParameterTypeRequiredSubmission MethodDefaultDescription
tokenStringYheaderNoneAccess token
tagIdIntYbodyNoneWritable data-point ID
valueIntYbodyValue to write
  • Parameter Description

Commands can be issued only to writable points through tagId. value must be a decimal value.

  • Response Parameters
ParameterTypeFieldDescription
codeIntError code
messageStringError message