Configuration

Neuron provide a series of API services for IIoT platform, to query the basic information, to control gateway behaviors or to setup the polling configuration. IIoT platform can initiate the communication by sending request message to Neuron. By return, Neuron would send back the required information or execute the deserved action. If there is error, a error code would be returned to tell the reason of failure.

Ping

POST /api/v2/ping

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Login

POST /api/v2/login

Request Headers

Content-Type application/json

Response Status

  • 200 OK
  • 401
    • 1004, 缺少令牌
    • 1005, 解码令牌错误
  • 403
    • 1006, 令牌过期
    • 1007, 验证令牌错误
    • 1008, 无效令牌

Body

  1. {
  2. "name": "admin",
  3. "pass": "0000"
  4. }

Response

  1. {
  2. "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzcyODcxNjMsImlhdCI6MTYzNzIwMDc2MywiaXNzIjoiRU1RIFRlY2hub2xvZ2llcyBDby4sIEx0ZCBBbGwgcmlnaHRzIHJlc2VydmVkLiIsInBhc3MiOiIwMDAwIiwidXNlciI6ImFkbWluIn0.2EZzPC9djErrCeYNrK2av0smh-eKxDYeyu7cW4MyknI"
  3. }

Password

POST /api/v2/password

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 401
    • 1004 missing token
    • 1005 decoding token error
    • 1012 password length too short or too long
    • 1013 duplicate password
  • 403
    • 1006 expired token
    • 1007 validate token error
    • 1008 invalid token

Body

  1. {
  2. "name": "admin",
  3. "old_pass": "01234",
  4. "new_pass": "56789"
  5. }

Response

  1. {
  2. "error": 0
  3. }

Add Node

POST /api/v2/node

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2001 node type invalid
  • 404
    • 2301 library not found
  • 409
    • 2002 node exist

Body

  1. {
  2. //node name
  3. "name": "modbus-tcp-node",
  4. //plugin name
  5. "plugin": "Modbus TCP"
  6. }

Response

  1. {
  2. "error": 0
  3. }

Del Node

Delete /api/v2/node

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2003 node not exist

Body

  1. {
  2. //node name
  3. "name": "modbus-tcp-node"
  4. }

Response

  1. {
  2. "error": 0
  3. }

Update Node

PUT /api/v2/node

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2013 node not allow update
    • 2015 node name is empty
  • 404
    • 2003 node not exist
  • 409
    • 2002 node exist
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "name": "modbus-node",
  3. "new_name": "modbus-tcp-node"
  4. }

Response

  1. {
  2. "error": 0
  3. }

Get Node

GET /api/v2/node

Request Params

type required

plugin optional

node optional

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Response

  1. {
  2. "nodes": [
  3. {
  4. //node name
  5. "name": "sample-driver-adapter",
  6. //plugin name
  7. "plugin": "Modbus TCP"
  8. },
  9. {
  10. "name": "modbus-tcp-adapter",
  11. "plugin": "Modbus TCP"
  12. }
  13. ]
  14. }

Node Setting

POST /api/v2/node/setting

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2003 node not exist
    • 2004 node setting invalid

Body

  1. //The parameter fields in json fill in different fields according to different plugins
  2. {
  3. //node name
  4. "node": "modbus-node",
  5. "params": {
  6. "param1": 1,
  7. "param2": "1.1.1.1",
  8. "param3": true,
  9. "param4": 11.22
  10. }
  11. }

TIP

Please refer to Plugin Setting for the configuration parameters of each plugin.

Response

  1. {
  2. "error": 0
  3. }

Get Node Setting

GET /api/v2/node/setting

Request Params

node required

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
    • 2005 node setting not found
  • 404
    • 2003 node not exist

Response

  1. //The parameter fields in json fill in different fields according to different plugins
  2. {
  3. "node": "modbus-node",
  4. "params": {
  5. "param1": "1.1.1.1",
  6. "param2": 502
  7. }
  8. }

Node CTL

POST /api/v2/node/ctl

Request Headers

Content-Type application/json

Authorization Bearer <token>

Request Status

  • 200 OK
  • 409
    • 2006 node not ready
    • 2007 node is running
    • 2008 node not running
    • 2009 node is stopped

Body

  1. {
  2. //node name
  3. "node": "modbus-node",
  4. //0 start, 1 stop
  5. "cmd": 0
  6. }

Response

  1. {
  2. "error": 0
  3. }

Get Node State

GET /api/v2/node/state

Request Params

node optional

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Response

  1. {
  2. "states": [
  3. {
  4. // node name
  5. "node": "modbus-node1",
  6. //running state
  7. "running": 2,
  8. //link state
  9. "link": 1,
  10. //average round trip time communicating with devices
  11. "rtt": 100
  12. },
  13. {
  14. "node": "modbus-node2",
  15. "running": 1,
  16. "link": 0,
  17. "rtt": 9999
  18. }
  19. ]
  20. }

Add Group

POST /api/v2/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2003 node not exist
  • 409
    • 2103 group not allow

Body

  1. {
  2. //group name
  3. "name": "gconfig1",
  4. //node name
  5. "node": "modbus-node",
  6. //read/upload interval(ms)
  7. "interval": 10000
  8. }

Response

  1. {
  2. "error": 0
  3. }

Del Group

DELETE /api/v2/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 412
    • 2101 group already subscribed
  • 404
    • 2003 node not exist
    • 2106 group not exist

Body

  1. {
  2. //node name
  3. "node": "modbus-node",
  4. //group name
  5. "group": "gconfig1"
  6. }

Response

  1. {
  2. "error": 0
  3. }

Update Group

PUT /api/v2/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2106 group not exist

Body

  1. {
  2. //group name
  3. "group": "gconfig1",
  4. //node name
  5. "node": "modbus-node",
  6. //read/upload interval(ms)
  7. "interval": 10000
  8. }

Response

  1. {
  2. "error": 0
  3. }

Get Group

GET /api/v2/group

Request Params

node optional

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Response

  1. {
  2. "groups": [
  3. {
  4. //group name
  5. "name": "config_modbus_tcp_sample_2",
  6. //read/upload interval(ms)
  7. "interval": 2000,
  8. //tag count
  9. "tag_count": 0
  10. },
  11. {
  12. "name": "gconfig1",
  13. "interval": 10000,
  14. "tag_count": 0
  15. }
  16. ]
  17. }

Add Tag

POST /api/v2/tags

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 206
    • 2202 tag name conflict
    • 2203 tag attribute not support
    • 2204 tag type not support
    • 2205 tag address format invalid
  • 404
    • 2003 node not exist

Body

  1. {
  2. //node name
  3. "node": "modbus-node",
  4. //group name
  5. "group": "config_modbus_tcp_sample_2",
  6. "tags": [
  7. {
  8. //tag name
  9. "name": "tag1",
  10. //tag address
  11. "address": "1!400001",
  12. //tag attribute
  13. "attribute": 8,
  14. //tag type
  15. "type": 4,
  16. //optional, float/double precision, optional(0-17)
  17. "precision": 0,
  18. //optional, decimal
  19. "decimal": 0,
  20. //optional, description
  21. "description": "",
  22. //optional, when the attribute is static,the value field needs to be added.
  23. "value": 12
  24. },
  25. {
  26. "name": "tag2",
  27. "address": "1!00001",
  28. "attribute": 3,
  29. "type": 3,
  30. "decimal": 0.01
  31. },
  32. {
  33. "name": "tag3",
  34. "address": "1!400009",
  35. "attribute": 3,
  36. "type": 9,
  37. "precision": 3
  38. },
  39. {
  40. "name": "static_tag",
  41. "address": "",
  42. "attribute": 10,
  43. "type": 1,
  44. "description": "It is a static tag",
  45. "value": 42
  46. }
  47. ]
  48. }

Response

  1. {
  2. "index": 1,
  3. "error": 0
  4. }

Get Tag

GET /api/v2/tags

Request Params

node required

group required

name optional

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2003 node not exist

Response

  1. {
  2. "tags": [
  3. {
  4. //tag name
  5. "name": "tag1",
  6. //tag type
  7. "type": 4,
  8. //tag address
  9. "address": "1!400001",
  10. //tag attribute
  11. "attribute": 8,
  12. //description
  13. "description": "",
  14. //float/double precision
  15. "precision": 0,
  16. //decimal
  17. "decimal": 0,
  18. //optional, when the attribute is static
  19. "value": 12
  20. },
  21. {
  22. "name": "tag2",
  23. "type": 14,
  24. "address": "1!00001",
  25. "attribute": 3,
  26. "description": "",
  27. "precison": 0,
  28. "decimal": 0,
  29. },
  30. {
  31. "name": "tag3",
  32. "type": 11,
  33. "address": "1!400009",
  34. "attribute": 3,
  35. "description": "",
  36. "precison": 0,
  37. "decimal": 0,
  38. }
  39. ]
  40. }

Update Tag

PUT /api/v2/tags

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response status

  • 200 OK
  • 206
    • 2201 tag not exist
    • 2202 tag name conflict
    • 2203 tag attribute not support
    • 2204 tag type not support
    • 2205 tag address format invalid
  • 404
    • 2003 node not exist
    • 2106 group not exist

Body

  1. {
  2. //node name
  3. "node": "modbus-tcp-test",
  4. //group name
  5. "group": "group1",
  6. "tags": [
  7. {
  8. //tag name
  9. "name": "tag1",
  10. //tag type
  11. "type": 8,
  12. //tag attribute
  13. "attribute": 0,
  14. //tag address
  15. "address": "1!400001",
  16. //description
  17. "description":"",
  18. //float/double precison
  19. "precision": 0,
  20. //decimal
  21. "decimal": 0,
  22. //optional, when the attribute is static,the value field needs to be added.
  23. "value": 12
  24. },
  25. {
  26. "name": "tag2",
  27. "type": 6,
  28. "attribute": 0,
  29. "address": "1!400002",
  30. "description":"",
  31. "precison": 0,
  32. "decimal": 0,
  33. },
  34. {
  35. "name": "static_tag",
  36. "address": "",
  37. "attribute": 10,
  38. "type": 8,
  39. "description":"",
  40. "precison": 0,
  41. "decimal": 0,
  42. "value": 42
  43. }
  44. ]
  45. }

Response

  1. {
  2. "error": 0,
  3. "index": 1
  4. }

Del Tag

DELETE /api/v2/tags

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2003 node not exist

Body

  1. {
  2. //group name
  3. "group": "config_modbus_tcp_sample_2",
  4. //node name
  5. "node": "modbus-node",
  6. //tag name
  7. "tags": [
  8. "tag1",
  9. "tag2"
  10. ]
  11. }

Response

  1. {
  2. "error": 0
  3. }

Add Plugin

POST /api/v2/plugin

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK

  • 400

    • 2302 library info invalid

Body

  1. {
  2. //plugin library name
  3. "library": "plugin_name.so"
  4. }

Response

  1. {
  2. "error": 0
  3. }

Del Plugin

DELETE /api/v2/plugin

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK

Body

  1. {
  2. //plugin name
  3. "plugin": "modbus-tcp"
  4. }

Response

  1. {
  2. "error": 0
  3. }

Get Plugin

GET /api/v2/plugin

Request Params

plugin optional

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Response

  1. {
  2. "plugins": [
  3. {
  4. //plugin kind
  5. "kind": 1,
  6. //node type
  7. "node_type": 1,
  8. //plugin name
  9. "name": "Modbus TCP",
  10. //plugin library name
  11. "library": "libplugin-modbus-tcp.so",
  12. "description": "description",
  13. "description_zh": "描述",
  14. "schema": "modbus-tcp"
  15. },
  16. {
  17. "kind": 1,
  18. "node_type": 2,
  19. "name": "MQTT",
  20. "library": "libplugin-mqtt.so",
  21. "description": "Neuron northbound MQTT plugin bases on NanoSDK.",
  22. "description_zh": "基于 NanoSDK 的 Neuron 北向应用 MQTT 插件",
  23. "schema": "mqtt"
  24. }
  25. ]
  26. }

Get Plugin Schema

GET /api/v2/schema

Request Params

schema_name required

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK

Response

  1. {
  2. "tag_regex": [
  3. {
  4. "type": 3,
  5. "regex": "^[0-9]+![3-4][0-9]+(#B|#L|)$"
  6. },
  7. {
  8. "type": 4,
  9. "regex": "^[0-9]+![3-4][0-9]+(#B|#L|)$"
  10. },
  11. {
  12. "type": 5,
  13. "regex": "^[0-9]+![3-4][0-9]+(#BB|#BL|#LL|#LB|)$"
  14. },
  15. {
  16. "type": 6,
  17. "regex": "^[0-9]+![3-4][0-9]+(#BB|#BL|#LL|#LB|)$"
  18. },
  19. {
  20. "type": 7,
  21. "regex": "^[0-9]+![3-4][0-9]+(#B|#L|)$"
  22. },
  23. {
  24. "type": 8,
  25. "regex": "^[0-9]+![3-4][0-9]+(#B|#L|)$"
  26. },
  27. {
  28. "type": 9,
  29. "regex": "^[0-9]+![3-4][0-9]+(#BB|#BL|#LL|#LB|)$"
  30. },
  31. {
  32. "type": 10,
  33. "regex": "^[0-9]+![3-4][0-9]+(#B|#L|)$"
  34. },
  35. {
  36. "type": 11,
  37. "regex": "^[0-9]+!([0-1][0-9]+|[3-4][0-9]+\\.([0-9]|[0-1][0-5]))$"
  38. },
  39. {
  40. "type": 13,
  41. "regex": "^[0-9]+![3-4][0-9]+\\.[0-9]+(H|L|)$"
  42. }
  43. ],
  44. "group_interval": 1000,
  45. "connection_mode": {
  46. "name": "Connection Mode",
  47. "name_zh": "连接模式",
  48. "description": "Neuron as the client, or as the server",
  49. "description_zh": "Neuron 作为客户端或服务端",
  50. "attribute": "required",
  51. "type": "map",
  52. "default": 0,
  53. "valid": {
  54. "map": [
  55. {
  56. "key": "Client",
  57. "value": 0
  58. },
  59. {
  60. "key": "Server",
  61. "value": 1
  62. }
  63. ]
  64. }
  65. },
  66. "interval": {
  67. "name": "Send Interval",
  68. "name_zh": "指令发送间隔",
  69. "description": "Send reading instruction interval(ms)",
  70. "description_zh": "发送读指令时间间隔,单位为毫秒",
  71. "attribute": "required",
  72. "type": "int",
  73. "default": 20,
  74. "valid": {
  75. "min": 0,
  76. "max": 3000
  77. }
  78. },
  79. "host": {
  80. "name": "IP Address",
  81. "name_zh": "IP地址",
  82. "description": "Local IP in server mode, remote device IP in client mode",
  83. "description_zh": "服务端模式中填写本地 IP,客户端模式中填写目标设备 IP",
  84. "attribute": "required",
  85. "type": "string",
  86. "valid": {
  87. "regex": "/^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$/",
  88. "length": 30
  89. }
  90. },
  91. "port": {
  92. "name": "Port",
  93. "name_zh": "端口号",
  94. "description": "Local port in server mode, remote device port in client mode",
  95. "description_zh": "服务端模式中填写本地端口号,客户端模式中填写远程设备端口号",
  96. "attribute": "required",
  97. "type": "int",
  98. "default": 502,
  99. "valid": {
  100. "min": 1,
  101. "max": 65535
  102. }
  103. },
  104. "timeout": {
  105. "name": "Connection Timeout",
  106. "name_zh": "连接超时时间",
  107. "description": "Connection timeout(ms)",
  108. "description_zh": "连接超时时间,单位为毫秒",
  109. "attribute": "required",
  110. "type": "int",
  111. "default": 3000,
  112. "valid": {
  113. "min": 1000,
  114. "max": 65535
  115. }
  116. }
  117. }

Subscribe

POST /api/v2/subscribe

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2106 group not exist

Body

  1. {
  2. //app name
  3. "app": "mqtt",
  4. //driver name
  5. "driver": "modbus-tcp",
  6. //driver node group name
  7. "group": "group-1",
  8. //optional, when using the MQTT plugin, the topic field needs to be added
  9. "params": {
  10. "topic": "/neuron/mqtt/group-1"
  11. }
  12. }

Response

  1. {
  2. "error": 0
  3. }

UnSubscribe

DELETE /api/v2/subscribe

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2106 group not exist

Body

  1. {
  2. //app name
  3. "app": "mqtt",
  4. //driver name
  5. "driver": "modbus-tcp",
  6. //driver node group name
  7. "group": "group-1",
  8. //optional, when using the MQTT plugin, the topic field needs to be added
  9. "params": {
  10. "topic": "/neuron/mqtt/group-1"
  11. }
  12. }

Response

  1. {
  2. "error": 0
  3. }

Get Subscribe Group

GET /api/v2/subscribe

Request Params

app required

Request Headers

Authorization Bearer <token>

Response Status

  • 200
  • 400

Response

  1. {
  2. "groups": [
  3. {
  4. //driver name
  5. "driver": "modbus-tcp",
  6. //group name
  7. "group": "group-1",
  8. //when using the MQTT plugin, the topic field needs to be added
  9. "params": {
  10. "topic": "/neuron/mqtt/group-1"
  11. }
  12. },
  13. {
  14. //driver name
  15. "driver": "modbus-tcp",
  16. //group name
  17. "group": "group-2",
  18. //when using the MQTT plugin, the topic field needs to be added
  19. "params": {
  20. "topic": "/neuron/mqtt/group-2"
  21. }
  22. }
  23. ]
  24. }

Get Version

GET /api/v2/version

Request Headers

Authorization Bearer <token>

Response Status

  • 200
  • 500
    • 1001 internal error

Response

  1. {
  2. "build_date": "2022-06-01",
  3. "revision": "99e2184+dirty", // dirty indicates uncommit changes
  4. "version": "2.4.0"
  5. }

Upload License

POST /api/v2/license

Request Headers

Authorization Bearer <token>

Response Status

  • 200
    • 0 OK
    • 2402 license expired
  • 400
    • 2401 license invalid
  • 500
    • 1001 internal error

Body

  1. {
  2. "license": "-----BEGIN CERTIFICATE-----\nMIID2TCCAsGgAwIBAgIEATSJqjA....."
  3. }

Response

  1. {
  2. "error": 2401
  3. }

Get License Info

GET /api/v2/license

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2400 license not found
  • 500
    • 1001 internal error

Response

  1. {
  2. "valid_until": "2023-03-15 08:11:19",
  3. "valid_since": "2022-03-15 08:11:19",
  4. "valid": false,
  5. "max_nodes": 1,
  6. "max_node_tags": 1,
  7. "used_nodes": 12,
  8. "used_tags": 846,
  9. "license_type": "retail",
  10. "error": 0,
  11. "enabled_plugins": [
  12. "MODBUS TCP Advance",
  13. "OPC UA"
  14. ],
  15. "hardware_token": "I+kZidSifiyVSbz0/EgcM6AcefnlfR4IU19ZZUnTS18=",
  16. "object": "emq",
  17. "email_address": "emq@emqx.io"
  18. }

Download log files

GET /api/v2/logs

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 1011 file not exist
    • 1014 command execution failed
  • 500
    • 1001 internal error

Response

Response if there is an error returned:

  1. {
  2. "error": 1014
  3. }

Update node log level

PUT /api/v2/log/level

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2003 node not exist
  • 500
    • 1001 internal error
    • 1010 is busy

Body

  1. {
  2. "node_name": "modbus-tcp"
  3. }

Response

  1. {
  2. "error": 0
  3. }

TIP

Call the api to modify the log level of the node to debug, and automatically switch to the default level in about ten minutes.

Download File

GET /api/v2/file

Request Headers

Authorization Bearer <token>

Request Params

file_path Required, absolute path of the file

Response Status

  • 404
    • 1011 file not exist
    • 4101 file open failure
    • 4102 file read failure

Response

Return the contents of the file and download the file, when responding correctly.

Return the error code, when an error response occurs.

  1. {
  2. "error": 1011
  3. }

Get file list information

GET /api/v2/file/info

Request Headers

Authorization Bearer <token>

Request Params

dir_path Required, absolute path of the directory.

Response Status

  • 404
    • 1011 file not exist
    • 4101 file open failure

Response

Response to the file name, size, creation time and update time, when responding correctly.

  1. {
  2. "files": [
  3. {
  4. "name": "neuron",
  5. "size": 4096,
  6. "ctime": "Wed Jan 4 02:38:12 2023",
  7. "mtime": "Mon Dec 26 09:48:42 2022"
  8. },
  9. {
  10. "name": "test.txt",
  11. "size": 13,
  12. "ctime": "Wed Jan 4 02:38:12 2023",
  13. "mtime": "Mon Dec 26 09:48:42 2022"
  14. }
  15. ]
  16. }

Response to the error code, when an error response occurs.

  1. {
  2. "error": 1011
  3. }

Add Template

POST /api/v2/template

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 206
    • 2203 tag attribute not support
    • 2204 tag type not support
    • 2205 tag address format invalid
    • 2206 tag name too long
    • 2207 tag address too long
    • 2208 tag description too long
    • 2209 tag precision invalid
  • 400
    • 2105 group parameter invalid
    • 2107 group name too long
    • 2502 template name too long
    • 3013 plugin name too long
    • 3016 plugin does not support template
  • 404
    • 3014 plugin not found
  • 409
    • 2104 group exist
    • 2202 tag name conflict
    • 2500 template already exists
  • 500
    • 1010 server is busy
    • 1001 internal error

Body

  1. {
  2. "name": "rtu template",
  3. "plugin": "Modbus RTU",
  4. "groups": [
  5. {
  6. "name": "group1",
  7. "interval": 2000,
  8. "tags": [
  9. {
  10. "name": "tag1",
  11. "type": 4,
  12. "address": "1!400001",
  13. "attribute": 1,
  14. "precison": 1,
  15. "decimal": 0
  16. },
  17. {
  18. "name": "tag2",
  19. "type": 11,
  20. "address": "1!400009",
  21. "attribute": 3
  22. }
  23. ]
  24. }
  25. ]
  26. }

Response

  1. {
  2. "error": 0
  3. }

Delete Template

DELETE /api/v2/template

Request Headers

Content-Type application/json

Authorization Bearer <token>

Request Params

name optional, name of the template to delete. If not specified, then delete all templates.

Response Status

  • 200 OK
  • 404
    • 2501 template not found
  • 500
    • 1010 server is busy

Response

  1. {
  2. "error": 0
  3. }

Get Template

GET /api/v2/template

Request Headers

Content-Type application/json

Authorization Bearer <token>

Request Params

name optional, name of a particular template.

Response Status

  • 200 OK
  • 400
    • 1003 request param invalid
  • 404
    • 2501 template not found
  • 500
    • 1001 internal error
    • 1010 server is busy

Response

Without the name request parameter, return all templates.

  1. {
  2. "templates": [
  3. {
  4. "name": "template1",
  5. "plugin": "modbus tcp"
  6. },
  7. {
  8. "name": "template2",
  9. "plugin": "opc ua"
  10. }
  11. ]
  12. }

When the name request parameter is specified, return detail information of the template of the given name.

  1. {
  2. "name": "rtu template",
  3. "plugin": "Modbus RTU",
  4. "groups": [
  5. {
  6. "name": "group1",
  7. "interval": 2000,
  8. "tags": [
  9. {
  10. "name": "tag1",
  11. "type": 4,
  12. "address": "1!400001",
  13. "attribute": 1,
  14. "precison": 1,
  15. "decimal": 0
  16. },
  17. {
  18. "name": "tag2",
  19. "type": 11,
  20. "address": "1!400009",
  21. "attribute": 3
  22. }
  23. ]
  24. }
  25. ]
  26. }

Instantiate Template

POST /api/v2/template/inst

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2304 library failed to open
    • 2502 template name too long
  • 404
    • 2301 library not found
    • 2501 template not found
  • 409
    • 2002 node exist
    • 2307 library not allow create instance
  • 500
    • 1001 internal error
    • 1010 server is busy

Body

  1. {
  2. "name": "rtu template",
  3. "node": "modbus-rtu",
  4. }

Response

  1. {
  2. "error": 0
  3. }

Add Template Group

POST /api/v2/template/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2105 group parameter invalid
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2501 template not found
  • 409
    • 2104 group exist
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1",
  4. "interval": 10000
  5. }

Response

  1. {
  2. "error": 0
  3. }

Del Template Group

DELETE /api/v2/template/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1"
  4. }

Response

  1. {
  2. "error": 0
  3. }

Update Group

PUT /api/v2/template/group

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 2105 group parameter invalid
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1",
  4. "interval": 20000
  5. }

Response

  1. {
  2. "error": 0
  3. }

Get Template Group

GET /api/v2/template/group

Request Params

name required, name of the template.

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 1003 request param invalid
  • 404
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Response

  1. {
  2. "groups": [
  3. {
  4. "name": "group1",
  5. "interval": 2000,
  6. "tag_count": 2
  7. }
  8. ]
  9. }

Add Template Tag

POST /api/v2/template/tag

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 206
    • 2203 tag attribute not support
    • 2204 tag type not support
    • 2205 tag address format invalid
    • 2206 tag name too long
    • 2207 tag address too long
    • 2208 tag description too long
    • 2209 tag precision invalid
  • 400
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 409
    • 2202 tag name conflict
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1",
  4. "tags": [
  5. {
  6. "name": "tag1",
  7. "address": "1!400001",
  8. "attribute": 8,
  9. "type": 4,
  10. "precision": 0,
  11. "decimal": 0,
  12. "description": "",
  13. "value": 12
  14. },
  15. {
  16. "name": "tag2",
  17. "address": "1!00001",
  18. "attribute": 3,
  19. "type": 3,
  20. "decimal": 0.01
  21. }
  22. ]
  23. }

Response

  1. {
  2. "index": 2,
  3. "error": 0
  4. }

Update Template Tag

PUT /api/v2/template/tag

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response status

  • 200 OK
  • 206
    • 2201 tag not exist
    • 2203 tag attribute not support
    • 2204 tag type not support
    • 2205 tag address format invalid
    • 2206 tag name too long
    • 2207 tag address too long
    • 2208 tag description too long
    • 2209 tag precision invalid
  • 400
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1",
  4. "tags": [
  5. {
  6. "name": "tag1",
  7. "address": "1!400001",
  8. "attribute": 8,
  9. "type": 4,
  10. "precision": 0,
  11. "decimal": 0,
  12. "description": "",
  13. "value": 12
  14. },
  15. {
  16. "name": "tag2",
  17. "address": "1!00001",
  18. "attribute": 3,
  19. "type": 3,
  20. "decimal": 0.01
  21. }
  22. ]
  23. }

Response

  1. {
  2. "index": 2,
  3. "error": 0
  4. }

Del Template Tag

DELETE /api/v2/template/tag

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 206
    • 2206 tag name too long
  • 400
    • 2107 group name too long
    • 2502 template name too long
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Body

  1. {
  2. "template": "modbus-template",
  3. "group": "group1",
  4. "tags": [
  5. "tag1",
  6. "tag2"
  7. ]
  8. }

Response

  1. {
  2. "error": 0
  3. }

Get Template Tag

GET /api/v2/template/tag

Request Params

template required, name of the template.

group required, name of the group.

name optional, to filter by tag name.

Request Headers

Authorization Bearer <token>

Response Status

  • 200 OK
  • 400
    • 1003 request param invalid
  • 404
    • 2106 group not exist
    • 2501 template not found
  • 500
    • 1001 internal server error
    • 1010 server is busy

Response

  1. {
  2. "tags": [
  3. {
  4. "name": "tag1",
  5. "type": 4,
  6. "address": "1!400001",
  7. "attribute": 8,
  8. "description": "",
  9. "precision": 0,
  10. "decimal": 0,
  11. "value": 12
  12. },
  13. {
  14. "name": "tag2",
  15. "type": 14,
  16. "address": "1!00001",
  17. "attribute": 3,
  18. "description": "",
  19. "precison": 0,
  20. "decimal": 0,
  21. }
  22. ]
  23. }