diacloud API文档说明v1.4.zh-CN.en

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Translated from Chinese (Simplified) to English - www.onlinedoctranslator.

com

Diacloud APIinterface documentation

V1.4

A modified version Modified date Modify the content

V1.3 2020-06-05 ➢ Add chapter number


➢ Added:
➢ F4:Dwordand floating point arithmetic
➢ F5: The current data interface of the device register cannot be obtainedMDistrict
data?

➢ F6: The current data interface of the device register, the obtained data is incomplete?
➢ F7:APIcall limit
V1.4 2020-06-17 ➢ Time zone declaration for the interface

➢ Interface renaming: only name modification, others remain unchanged

➢ The original interface "Get Register History Data Interface" was renamed "Get

Single History Data Interface"

➢ The original interface "Get the current data interface of the device register" was renamed

"Press UTC+8Clock Get Device Register Current Data Interface"

➢ The original interface "all equipmentalarm"Information Interface" was renamed

"Press UTC+8Clock Get All Devicesalarminformation interface"

➢ The original interface "single devicealarm"Information Interface" was renamed

"Press UTC+8Clock to get a single devicealarminformation interface"

➢ Interface changes:

➢ Get a single historical data interface, add support for fixed time interval query

parameters

➢ new interface

➢ new1: Get register history by register configuration

➢ new2:according toUTCClock Get Device Register Current Data Interface

➢ new3:according toUTCClock Get All DevicesalarmInformation interface

➢ new4:according toUTCClock to get a single devicealarmInformation interface

➢ FAQ-F8: How to upload communication error flags


content

one,DIACloud APIInterface Description................................................ ...................................................... ...3

1.1 Diaclou APIInterface Introduction ................................................ ...................................................... ....3

1.2Device basic information interface...................................................... ...................................................... ........4

1.3according toUTC+8Get all devicesalarmInformation interface...................................................... ......................................6

1.4according toUTC+8Get a single devicealarmInformation interface...................................................... ......................................9

1.5Security Tunnel List Information Interface ..................................................... ......................................................12

1.6according toUTC+8Get the current data interface of the device register...................................................... ......................13

1.7Set Device Register Value Interface ..................................................... ......................................................16

1.8Get Register History Data Interface ..................................................................... ......................................................17

1.9Delete a certain register interface of the device...................................................... ......................................................20

1.10Get the values of certain registers of each device...................................................... ......................................20

1.11according toUTCGet all devicesalarmInformation interface...................................................... ......................................twenty two

1.12according toUTCGet a single devicealarmInformation interface...................................................... ......................................25

1.13according toUTCGet the current data interface of the device register...................................................... ................................28

1.14Get historical data interface by register configuration ................................................ ......................................30

1.14.1Register Configuration Steps...................................................... .....................................................................30

1.14.2Introduction to the interface for obtaining historical data by register configuration................................................ ......................................31

FAQ:common problem............................................... ...................................................... ......................34

F1:transferAPIhint"please replace the variable in {} with the correct value” ................. 34

F2:transferAPIreturn403fobind ................................................. ............................................... 35

F3: Displays that the setting is successful, but does not take effect................................................ .....................................................35

F4:Dwordand floating-point arithmetic ................................................ ......................................................35

F5: The current data interface of the device register cannot be obtainedMDistrict data? ......................................................36

F6: The current data interface of the device register, the obtained data is incomplete? ...................................................... ......36

F7:APICall Restrictions ................................................ ...................................................... .............37

F8: How to upload communication error flags ................................................ ......................................................37


one,DIACloud APIInterface Description

1.1 Diaclou APIInterface Introduction

APIInterface description address:https://api.diacloudsolutions.com.cn/

APIInterface classification: equipment basic information interface, all equipmentalarmInformation interface, single devicealarmInformation interface, security

tunnel list information interface, interface for obtaining current data of device register, interface for setting device register value, interface for obtaining

historical data of register, interface for deleting device. The following table is introduced:

Json
name Restful APIs illustrate
request type

Get the basic information of the device under the account


Device basic information interface /devices get
information

Get all by UTC+8


Press UTC+8 to get all the accounts under this account
equipmentalarminformation connection /alarms get
alarms
mouth

Get a single unit by UTC+8


Press UTC+8 to get the specified under the account
equipmentalarminformation connection /devices/{device_id}/alarms get
device alarms
mouth

Secure Tunnel List Information Get all secure tunnels under the account
/vlns get
interface Information

according toUTC+8clock acquisition


Get the account under the UTC+8 clock
Current number of device registers /devices/{device_id}/regs get
The current value of a device register.
data interface

Set the number of device registers A certain device under the account of the device
/devices/{device_id}/regs put
value interface register value

Get the account under the account according to the change time

Get a single history number /devices/{device_id}/regs/{reg_addr}/


get The historical number of a register of a device
data interface history
according to

delete device register Delete a certain device under the account


/devices/{device_id}/regs/{reg_addr} delete
mouth register data
Return a certain time interval
Obtained by register configuration
/devices/{device_id}/regshistory get Account, a fixed interval for a device
Fetch register history
Multiple register history data over time

according toUTCclock acquisition Get the account under this account according to the UTC clock

device register current /v2/devices/{device_id}/regs get The current value of the device register.

Data interface

according toUTCclock acquisition Press UTC+8 to get all the accounts under this account

All equipmentalarm /v2/alarms get alarms

Information interface
according toUTCclock acquisition Press UTC+8 to get the specified under the account

single devicealarm /v2/devices/{device_id}/alarms get device alarms


Information interface

1.2Device basic information interface

Used to obtain the basic information of the device under the account

Json request format:


url:https://api.diacloudsolutions.com.cn/devices
method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password").

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the first one in the api list , select "basic auth" on the right

input indiacloudOn the registered cloud account, click [Refresh headers】


will generaterequest headers,

Click【Send], the returnedjson:


indataThe descriptions of the fields involved are as follows:

entry in data name illustrate

id device id The unique identifier of the device on the cloud platform

name Equipment name device alias


sn Device SN Unique ID of the device hardware

tunnel id Secure Tunnel ID ID number of the secure tunnel where the device is located

storage_state Cloud storage space status Whether the cloud storage space used by the device is full 1: normal, 0: used up

traffic_state Cloud traffic status Status of cloud traffic used by the device 1: normal, 0: used up

online online status Whether the device is online: 0 offline, 1 online

IP Device IP IP address of the device

Note: Only the latest version V1.4 and above has this information.

eip Public network entrance IP For example: TCP: 211.97.129.248, the device uses TCP to connect to

the server, and its corresponding exit IP is 211.97.129.248

Note: Only the latest version V1.4 and above has the delay for the
latency delay
information device to connect to the server, in ms

1.3according toUTC+8Get all devicesalarmInformation interface

Used to get all the alarms information of the device under this account.

Note: The Alarm refers to the alarm set in the device web page. The detailed settings are in the device web page, [System

Settings] -> [Event Management], and select "Alarm Event" in the event type.

Json request format:


url:https://api.diacloudsolutions.com.cn/alarms
method: get
Request header:
Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password").

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the second one in the api list , select "basic auth" on the right

input indiacloudOn the registered cloud account, click [Refresh headers】

will generaterequest headers,


Click【Send], the returnedjson:

The return request contains two parts

1,PagingPagination information

Entries in paging name illustrate

page which page

limt How many lines per page

total How many alarms are there in total

pagecount how many pages in total

offset offset

2,Datameaning in
entry in data name illustrate

device_id device id ID of the device where the alarm occurred

name Equipment name SMS alert name


title Alert title Alert title
content Alarm content Alarm content

SMS sending status Whether the SMS is sent successfully 0: success 1 is failure (only recorded when using
sms.result
state cloud SMS)

SMS sent
sms.addr The mobile phone number to which the SMS is sent
phone number

mail sending Whether the email is sent successfully 0: success 1 is failure (only recorded when using cloud
email.result
fruit SMS)

mail sending place


email.addr destination email address
site
The time when the alert was sent. The time is in the format UTC/GMT+08:00(East Eight
created send time
District time)

Note: Alarms support paging, query by time, etc.

If you query the second page then

https://api.diacloudsolutions.com.cn/alarms?page=2 If
query2018-01-01arrive2018-01-08
https://api.diacloudsolutions.com.cn/alarms?from=2018-01-01 00:00:00 & to=2018-01-09 00:00 Use & to
connect multiple conditions

1.4according toUTC+8Get a single devicealarmInformation interface

Used to obtain all the alarms information of a device under the account.

Note: Alert sources and1.3 Press UTC+8 to get all devicesalarmInformation interface The alarms in are all the alarms set in the webpage

of the source device. For specific settings, see1.3 Press UTC+8 to get all devicesalarmInformation interface . Json request format:

url:https://api.diacloudsolutions.com.cn/devices/{device_id}/alarms method:
get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669
then the url ishttps://api.diacloudsolutions.com.cn/devices/21669/alarms

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the third one in the api list , select "basic" on the right

auth", and enter the account number

existurlreplacement equipmentIDNo21907(devices with an alarmID,equipmentIDFor the query method, please refer to the first basic information

interface)
Click【Send], the returnedjson:

The return request contains two parts

3,PagingPagination information

Entries in paging name illustrate

page which page

limt How many lines per page

total How many alarms are there in total

pagecount how many pages in total

offset offset

4,Datameaning in
entry in data name illustrate

device_id device id ID of the device where the alarm occurred


name Equipment name SMS alert name
title Alert title Alert title
content Alarm content Alarm content

SMS sending status Whether the SMS is sent successfully 0: success 1 is failure (only recorded when using
sms.result
state cloud SMS)

SMS sent
sms.addr The mobile phone number to which the SMS is sent
phone number

mail sending Whether the email is sent successfully 0: success 1 is failure (only recorded when using cloud
email.result
fruit SMS)

mail sending place


email.addr destination email address
site
The time when the alert was sent. The time is in the format UTC/GMT+08:00(East Eight
created send time
District time)

Note: Alarms support paging, query by time, etc.

If you query the second page then

https://api.diacloudsolutions.com.cn/devices/21097/alarms?page=2
If query2018-01-01arrive2018-01-08
https://api.diacloudsolutions.com.cn/devices/21097/alarms?from=2018-01-01 00:00:00 &
to=2018-01-09 00:00
Use & to connect multiple conditions

1.5Security Tunnel List Information Interface

Used to obtain the basic information of the secure tunnel under the account

Json request format:


url:https://api.diacloudsolutions.com.cn/vlns
method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Introduction

to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the fourth one in the api list , select "basic auth" on the right
After filling in the account and password, click [Send], the returnedjson:

indataThe descriptions of the fields involved are as follows:

entry in data name illustrate

id Secure Tunnel ID Secure Tunnel ID Number

name secure tunnel name secure tunnel name

dhcp Whether DHCP is enabled 1: DHCP on, 0: DHCP off


RangeStart start IP DHCP starting IP address
IPMask subnet mask subnet mask

RangeEnd end IP DHCP ending IP address

1.6according toUTC+8Get the current data interface of the device register

Used to obtain the current register information of the specific device under the account

Json request format:


url:https://api.diacloudsolutions.com.cn/devices/{device_id}/regs method:
get
Request header:
Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669

then the url ishttps://api.diacloudsolutions.com.cn/devices/21669/regs


Note 1: The default return data starts from 2048. If you need to read the bit area data ($1536~$2047), you need to add the

start parameter, such as:

https://api.diacloudsolutions.com.cn/devices/21669/regs?start=1536 . Note2: If the account


is wrong or the deviceIDerror will return403 error. Note 3: This interface cannot be used to
obtain system register data before $1536.

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the fifth in the api list , select "basic auth" on the right
After filling in the account and password, fill in the deviceIDAfter that, click [Send], the returnedjson:

The response is divided into two parts,countanddata,middlecountis the number of registers. indataThe

descriptions of the fields involved are as follows:

entry in data name illustrate

Addr register address Register address (2048~4096)

Register value (unsigned decimal integer, other types need to


Value register value
converted

The time when the register value is uploaded. The format for this time is
Time time
UTC/GMT+08:00(East Eight District time).

templatet conversion script The original value needs to be processed and converted to the script displayed after the conversion

History Whether to save history 1, save history, 0: do not save history


innameThe properties need to be inhttps://api.diacloudsolutions.com.cn On the website of [Device List], select the device,

operate [More] -> [Register] on the far right, and more [Configuration] functions on the far right, and the corresponding alias.
1.7set device register value interface

Used to set specific device and register information under the account

Json request format:


url:https://api.diacloudsolutions.com.cn/devices/{device_id}/regs Method:
put
Request header:

Fill in the data to be sent in Body


[{"addr":2048,"value":100},{"addr":2049,"value":100}]

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, if the ID in data is 21669, the url ishttps://

api.diacloudsolutions.com.cn/devices/21669/regs Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the sixth in the api list , select "basic auth" on the right
After filling in the account and password, fill in the deviceIDAfter that, there arepostdatacontent in . Click【Send], the result will be returned.202

Indicates that the operation is complete. If other settings fail, please confirm whether the network and parameters are correct.

1.8Get register history data interface

Json request format for setting a certain register history information of a specific

device under the account:

url:https://api.diacloudsolutions.com.cn/devices/{device_id}/regs/{reg_addr }/
history
Request parameters:

page: optional

limit: Return quantity per page, optional

from: The start time parameter of the query history, optional. The time format isUTCclock, such as:2019-01-23 05:40:48. to: The

start time parameter of the query history, optional. The time format isUTCclock, such as:2019-01-23 05:40:48. gap: Fixed time

interval in seconds. If this parameter is default, the changed timestamp will be returned by default; if this parameter is filled,

the data will be returned at the set interval.


method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669 Note: The address of the

{reg_addr} register

Assuming that the historical data of the 2048 register with the device ID of 21907 needs to be obtained,

the url is https://api.diacloudsolutions.com.cn/devices/21907/regs/2048/history

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the sixth in the api list , select "basic auth" on the right

After filling in the account and password, fill in the deviceIDand register number, click [Send], the returnedjson:
The response is divided into two parts,paginganddata,middlecountis the number of registers.

1,PagingPagination information

Entries in paging name illustrate

page which page

limt How many lines per page

total How many data in total

pagecount how many pages in total

offset offset

in the picture abovedataThe descriptions of the fields involved are as follows:

entry in data value illustrate

2017-01- Register upload time, meaning 2017, 1


time
10T00:43:26.819317Z Jan 10 00:43:26 time zone 0 time zone
Device ID 21907 Register value upload time
register number 2048 The number of the register is 2048

register value 2017 The value of the register is 2017

Note: Register supports paging, query by time, etc.

If you query page 8 then


https://api.diacloudsolutions.com.cn/devices/21907/regs/2048/history?page=8 If query
2018-01-01arrive2018-01-08 https://api.diacloudsolutions.com.cn/devices/21907/regs/
2048/history?from=2018-01-01 00:00:00 & to=2018-01-09 00:00

iffromandtoThe parameters are all default, and the data within the last hour is returned by default, and the data is the most2000If the bar is at

equal time intervals, the request parameters are as follows. Inquire2020year2020-06-16One day of data, at regular intervals of60 Second.
https://api.diacloudsolutions.com.cn/devices/21907/regs/2048/history?from=2020-06-16
00:00:00 & to=2020-06-17 00:00:00&gap=60
ps: The historical data is called for a single time, and the number of returned records is the most1Ten thousand.

1.9Delete a device register interface

This interface is not yet open

1.10Get the values of certain registers of each device

the interfaceapiNot yet published on the website.

Used to and get the value of the specific register of all devices under this account.

JsonRequest format:

URL:https://api.diacloudsolutions.com.cn/regs?start={reg_start}&end={reg_end}
method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: where

{reg_start} needs to get the start address of the register number

Note: where {reg_end} needs to get the end address of the register number. Assuming that you need to get the historical data

of all the devices whose device IDs are 2048 and 2049 under your own account, the url is

https://api.diacloudsolutions.com.cn/regs?start=2048&end=2049 Introduction to

the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/ Since the interface has not yet been added to the API
list, just select one and then manually fill in the URL

Suppose you select the first one in the api list , select "basic auth" on the right
BundleURLchange tohttps://api.diacloudsolutions.com.cn/regs?start=2048&end=2049 input indiacloudOn
the registered cloud account, click [Refresh headers], will appearheadersContent.

After clicking send, the following information will appear:

The data structure of data in the above figure is

"device_id": [

"device_id": ,
"addr": 2048,

"value": 0,

"time": "2017-06-20 10:43:50",

"name": "temperature",

"template": "return val+\"℃\";",

"history": 1,

"device_name": "Yongfeng Sewage Plant"

entry in data name illustrate

Device_id device id The unique identifier of the device on the cloud platform

addr address register number

value value unsigned hex


The timestamp of the register upload. The format for this time is
time time
UTC/GMT+08:00(East Eight District time).

name register name register alias


template conversion script Conversion script entered in the cloud

History Whether to save history 1, save history, 0: do not save history

Device_name Equipment name device alias


traffic_state Cloud traffic status Status of cloud traffic used by the device 1: normal, 0: used up

1.11according toUTCGet all devicesalarmInformation interface

Used to get all the alarms information of the device under this account.

Note: The Alarm refers to the alarm set in the device web page. The detailed settings are in the device web page, [System

Settings] -> [Event Management], and select "Alarm Event" in the event type.

Json request format:


url:https://api.diacloudsolutions.com.cn/v2/alarms
method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password").

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

select the second one in the api list , select "basic auth" on the right

input indiacloudOn the registered cloud account, click [Refresh headers】

will generaterequest headers,


Click【Send], the returnedjson:

The return request contains two parts

1,PagingPagination information

Entries in paging name illustrate

page which page

limt How many lines per page

total How many alarms are there in total

pagecount how many pages in total

offset offset

2,Datameaning in
entry in data name illustrate

device_id device id ID of the device where the alarm occurred

name Equipment name SMS alert name


title Alert title Alert title
content Alarm content Alarm content

SMS sending status Whether the SMS is sent successfully 0: success 1 is failure (only recorded when using
sms.result
state cloud SMS)

SMS sent
sms.addr The mobile phone number to which the SMS is sent
phone number

mail sending Whether the email is sent successfully 0: success 1 is failure (only recorded when using cloud
email.result
fruit SMS)

mail sending place


email.addr destination email address
site
The time when the alert was sent. The format of the time is UTC time (0 time zone
created send time
time)

Note: Alarms support paging, query by time, etc.


If you query the second page then

https://api.diacloudsolutions.com.cn/v2/alarms?page=2 If
query2018-01-01arrive2018-01-08
https://api.diacloudsolutions.com.cn/v2/alarms?from=2018-01-01 00:00:00 & to=2018-01-09 00:00

Use & to connect multiple conditions

1.12according toUTCGet a single devicealarmInformation interface

Used to obtain all the alarms information of a device under the account.

Note: Alert sources and1.11 Get all device alarm information interface according to UTC The alarms in are all the alarms set in the

webpage of the source device. For specific settings, see1.10 Get all devices in UTCalarmInformation interface . Json request format:

url:https://api.diacloudsolutions.com.cn/v2/devices/{device_id}/alarms method:
get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669

then the url ishttps://api.diacloudsolutions.com.cn/v2/devices/21669/alarms

Introduction to the use of the cloud api interface:


open url:https://api.diacloudsolutions.com.cn/

Select the third "basic auth" in the api list , select the right

and enter the account number

existurlreplacement equipmentIDNo21907(devices with an alarmID,equipmentIDFor the query method, please refer to the first basic information

interface)

Click【Send], the returnedjson:


The return request contains two parts

3,PagingPagination information

Entries in paging name illustrate

page which page

limt How many lines per page

total How many alarms are there in total

pagecount how many pages in total

offset offset

4,Datameaning in
entry in data name illustrate

device_id device id ID of the device where the alarm occurred

name Equipment name SMS alert name


title Alert title Alert title
content Alarm content Alarm content

SMS sending status Whether the SMS is sent successfully 0: success 1 is failure (only recorded when using
sms.result
state cloud SMS)

SMS sent
sms.addr The mobile phone number to which the SMS is sent
phone number

mail sending Whether the email is sent successfully 0: success 1 is failure (only recorded when using cloud
email.result
fruit SMS)

mail sending place


email.addr destination email address
site
The time when the alert was sent. The time is in the format of the UTC clock (0 time zone
created send time
time)

Note: Alarms support paging, query by time, etc.

If you query the second page then

https://api.diacloudsolutions.com.cn/v2/devices/21097/alarms?page=2
If query2018-01-01arrive2018-01-08
https://api.diacloudsolutions.com.cn/v2/devices/21097/alarms?from=2018-01-01 00:00:00 &
to=2018-01-09 00:00
Use & to connect multiple conditions.

1.13according toUTCGet the current data interface of the device register

Used to obtain the current register information of the specific device under the account

Json request format:


url:https://api.diacloudsolutions.com.cn/v2/devices/{device_id}/regs method:
get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669

then the url ishttps://api.diacloudsolutions.com.cn/devices/21669/regs


Note 1: The default return data starts from 2048. If you need to read the bit area data ($1536~$2047), you need to add the

start parameter, such as:

https://api.diacloudsolutions.com.cn/devices/21669/regs?start=1536 . Note2: If the account


is wrong or the deviceIDerror will return403 error. Note 3: This interface cannot be used to
obtain system register data before $1536.
Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/

Select the api list, , select "basic auth" on the right

After filling in the account and password, fill in the deviceIDAfter that, click [Send], the returnedjson:

The response is divided into two parts,countanddata,middlecountis the number of registers. indataThe

descriptions of the fields involved are as follows:

entry in data name illustrate

Addr register address Register address (2048~4096)

Register value (unsigned decimal integer, other types need to


Value register value
converted

The time when the register value is uploaded. The time is in UTC
Time time
Clock (0 time zone).
templatet conversion script The original value needs to be processed and converted to the script displayed after the conversion

History Whether to save history 1, save history, 0: do not save history


innameThe properties need to be inhttps://api.diacloudsolutions.com.cn On the website of [Device List], select the device,

operate [More] -> [Register] on the far right, and more [Configuration] functions on the far right, and the corresponding alias.
1.14Get historical data interface by register configuration

The user can configure the type of the register on the website, and the data will be automatically combined in the background through this interface and returned.

1.14.1Register configuration steps

loginhttps://diacloudsolutions.com.cn/ Website, operate in [Device List]

Select ->[Configuration] in the [Register] page

The length can be changed, e.g.float,dword,word.


1.14.2Introduction to the interface for obtaining historical data by register configuration

Json request format:


url: https://api.diacloudsolutions.com.cn/devices/{device_id}/regshistory?regs={reg_addr1},
{reg_addr2}
Request parameters:

regs:Required. Format example: ?regs=:2048,2050


page: optional

limit: Return quantity per page, optional

from: The start time parameter of the query history, optional. The time format isUTCclock, such as:2019-01-23 05:40:48. to: The

start time parameter of the query history, optional. The time format isUTCclock, such as:2019-01-23 05:40:48. gap: Fixed time

interval in seconds. If this parameter is default, the default time interval returned is60seconds; if this parameter is filled, the

data will return data at the set interval.

method: get
Request header:

Note: authoriz is authentication, followed by the base64 encrypted result of ("username":"password"). Note: Please replace

{device_id} with the id in data in the device information interface. For example, the ID in data is 21669 Note: The address of the

{reg_addr} register

Assuming that the historical data of the 2048 and 2050 registers with the device ID of 35236 needs to be

obtained, the url is https://api.diacloudsolutions.com.cn/devices/35236/regshistory?regs=2048,2050

Introduction to the use of the cloud api interface:

open url:https://api.diacloudsolutions.com.cn/
Select in the api list, select "basic auth" on the right

After filling in the account and password, fill in the deviceIDand register number, click [Send], the returnedjson:

The response is divided into three parts, wherecodeandmsg, indicating the request

status. code:0indicates success, not0Indicates failure. msg:success,fail.

When the calling data does not have permission, it will return failure.

outer layerdatain, by6part composition

entry in external data name illustrate

device_id Device ID

reg_addr register address register number

alias_name register alias Alias configured in register configuration

The number of registers requested. (Since 2048 is a float


reg_len register length
and 2050 is a Dword, there are 4 registers in total)

history Whether to save history 1, save history, 0: do not save history

data internal data The returned historical data is in it

InsidedataThe descriptions of the fields involved are as follows:


entry in data value illustrate

Register upload time, meaning 2020


reg_time 2020-06-17T05:45:00Z year, Jun 17 05:24:26, timezone 0
timezone
Device_id 35236 Device ID

Reg_addr 2048 The number of the register is 2048

register value 0.00949 The value of the register is 0.00949

Note: Register supports paging, query by time, etc.

If query2020-06-16arrive2020-06-17 https://api.diacloudsolutions.com.cn/devices/35236/
regshistory?regs=2048,2050&from=2020-06-16 00:00:00 & to=2020-06-17 00:00 :00

iffromandtoThe parameters are all default, and the data within the last hour is returned by default, and the data is the most2000If the bar is at

equal time intervals, the request parameters are as follows. Inquire2020year2020-06-16One day of data, at regular intervals of90 Second.

https://api.diacloudsolutions.com.cn/devices/35236/regshistory?
regs=2048,2050&from=2020-06-16 00:00:00 & to=2020-06-17 00:00:00&gap=90
ps: The historical data is called for a single time, and the number of returned records is the most1Ten thousand.
FAQ:common problem

F1:transferAPIhint"please replace the variable in {} with

the correct value”

call to modify registerAPIsWhen prompted: "please replace the variable in {} with the correct value”? The prompt

is as follows:

This is because when modifying the value, you need topost dataThe content that needs to be modified is shown in the figure below, and the modified content must be the

register that has been uploaded to the cloud.


F2:transferAPIreturn403fobind

When returning an error message403, please check with the query information andURLis it right or not.

F3: Displays that the setting is successful, but does not take effect

When the register data is set, the success of its return means that the server receives the data and forwards it to the device. However, whether the device side has been

successfully executed, and whether it has received information that cannot be confirmed. Customers need to query and confirm by themselves through the interface for

obtaining the register value (generally,5After the internal data has not changed to the value that needs to be displayed, you need to retry) . set up
Unsuccessful problems usually have the following problems:

(1) The device network is unstable, network redialing often occurs, or the signal is poor. The data

(2) on the device side is read-only.

(3) Device-side data has been canceled to upload to the cloud.

F4:Dwordand floating point arithmetic

APIWhat is obtained is the original value of the original register, which is16Bit unsigned integer. Often used in regular use32

Integer and floating point display. It is formed by combining the values of two adjacent registers. Suppose we want to

combine values, register1($2048) value51590,register2($2049) value16268.

inDword:dwordvalue = register2value*65536+register1value =16268*65536+51590 Floating point: the

calculation needs to passdwordThe result is converted to float data jsScript example:convertfor thefloat

functions to convert floating point numbers

Ps:afordwordthe result of.


When debugging, the user can log in for the convenience of checking.www.diacloudsolutions.com.cn website, 【Equipment column

Table] in "Operation" -> "More" , in the pop-up window, select the registertable.
More can be configured in the register, the display type of the register, to check the conversion function written by yourself.

PS: The type of configuration here is just the front-end parsing script and will not affectAPIReturn value.

F5: The current data interface of the device register cannot be obtainedMDistrict data?

equipmentMRegional Planning for Register $1536to $2047, that is,M0Actually the register number is $1536,M1
is $1537 and so on toM511Yes2047. To getMarea, if you need to add search parameters?start=1536, an
example is as follows: https://api.diacloudsolutions.com.cn/devices/21669/regs?start=1536 .

F6: The current data interface of the device register, the obtained data is incomplete?

Get the current data interface of the device register, the default start parameter is from2048start. if usefulbitarea, as

shown below, with displayM0wait, it takesMIt starts withMarea. So it's not that the data is incomplete, butstartThe

parameter is wrong. how to get,Marea data, seeF5Can't get registerMarea data .


F7:APIcall limit

APIcalls, whether or not from the same sourceIP, as long as it is the same account, the number of calls per hour cannot exceed10000

times (each in the first chapterAPIIf the interface is called once, it is counted as one call), otherwise the account may be restricted from

calling within one hour.

SimultaneouslyAPIThe call is not free, please consult the corresponding supply channel for the specific cost.

F8: How to upload communication error flags

Communication error related register information is as follows:

register modbusaddress illustrate

DEC HEX Supported models

DX2100/DX2300
$900 900 384 RS232 ModbusNumber of master communication errors
(FW1.5later version)

$901 901 DX2100/DX2300


385 RS232 ModbusThe location of the first error
(FW1.5later version)

$902 902 DX2100/DX2300


386 RS232 Modbusfirst error code
(FW1.5later version)

DX2100/DX2300
$903 903 387 RS485 ModbusMaster station error number
(FW1.5later version)

DX2100/DX2300
$904 904 388 RS485 ModbusThe location of the first error
(FW1.5later version)

DX2100/DX2300
$905 905 389 RS485 Modbusfirst error code
(FW1.5later version)

DX2100/DX2300
$906 906 38A Modbus TCPnumber of errors
(FW1.5later version)

DX2100/DX2300
$907 907 38B Modbus TCPThe group of the first error
(FW1.5later version)

ModbusTCPRelative to the group where the first error is located DX2100/DX2300


$908 908 38C
Location (FW1.5later version)

DX2100/DX2300
$909 909 38D Modbus TCPfirst error code
(FW1.5later version)

Comprehensive instructionsModbus TCPand DX2100/DX2300


$910 910 38E
SiemensTCP communication status (0is normal,1error) (FW1.5later version)
$911 911 DX2100/DX2300
38F Siemens TCPnumber of errors
(FW1.5later version)
DX2100/DX2300
$912 912 390 Siemens TCPThe group of the first error
(FW1.5later version)
Siemens TCPThe relative position of the first error in the DX2100/DX2300
$913 913 391
group (FW1.5later version)

becauseapiThe communication status cannot be obtained, so it is necessary to passmodbus tcpRead the register data above and upload it to the

cloud. such as uploading485communication status.485The communication status related registers of the master station have error debugging903,

where the first article is located904, the first corresponding error code905. In the device web page,

【System Settings】->【Modbus TCP】,choose【Modbus TCPServer + Client] , click [Add


Add server]

Fill in the corresponding information as shown below. The figure below is the903After the register is associated to2200.After setting, click [Save]

【System Settings】->【Register Management】 , click [Add]


After completing the settings as shown in the figure below, click [Save], and then you can pass theapiRetrieval2200register value, and getPLC

communication status.

You might also like