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

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

json

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

Response

json

  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

json

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

Response

json

  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
    • 2004 node setting invalid
  • 404
    • 2301 library not found
  • 409
    • 2002 node exist

Body

json

  1. {
  2. //node name
  3. "name": "modbus-tcp-node",
  4. //plugin name
  5. "plugin": "Modbus TCP"
  6. //setting (optional)
  7. "params": {
  8. "param1": 1,
  9. "param2": "1.1.1.1",
  10. "param3": true,
  11. "param4": 11.22
  12. }
  13. }

Response

json

  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

json

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

Response

json

  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

json

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

Response

json

  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

json

  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

json

  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

json

  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

json

  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

json

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

Response

json

  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

json

  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. //log level
  13. "log_level": "notice"
  14. },
  15. {
  16. "node": "modbus-node2",
  17. "running": 1,
  18. "link": 0,
  19. "rtt": 9999,
  20. "log_level": "notice"
  21. }
  22. ],
  23. //log level of neuron.log
  24. "neuron_core": "notice"
  25. }

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

json

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

Response

json

  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

json

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

Response

json

  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
    • 2003 node not exist
    • 2106 group not exist
  • 409
    • 2104 group exist

Body

To update group name:

json

  1. {
  2. //node name
  3. "node": "modbus-node",
  4. //group name
  5. "group": "gconfig1",
  6. //group new name
  7. "new_name": "group1"
  8. }

To update group interval:

json

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

To update both group name and interval:

json

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

Response

json

  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

json

  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

json

  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

json

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

Add Tag across multiple groups

POST /api/v2/gtags

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
    • 2106 group not exist

Body

json

  1. {
  2. //node name
  3. "node": "modbus-node",
  4. "groups": [
  5. {
  6. //group name
  7. "group": "group_1",
  8. //group interval
  9. "interval": 3000,
  10. "tags": [
  11. {
  12. //tag name
  13. "name": "tag1",
  14. //tag address
  15. "address": "1!400001",
  16. //tag attribute
  17. "attribute": 3,
  18. //tag type
  19. "type": 3,
  20. //optional, float/double precision, optional(0-17)
  21. "precision": 0,
  22. //optional, decimal
  23. "decimal": 0,
  24. //optional, description
  25. "description": "",
  26. //optional, when the attribute is static,the value field needs to be added.
  27. "value": 12
  28. },
  29. {
  30. "name": "tag2",
  31. "address": "1!400002",
  32. "attribute": 3,
  33. "type": 9,
  34. "precision": 3
  35. }
  36. ]
  37. },
  38. {
  39. "group": "group_2",
  40. "interval": 3000,
  41. "tags": [
  42. {
  43. "name": "tag1",
  44. "address": "1!400003",
  45. "attribute": 3,
  46. "type": 9,
  47. "precision": 3
  48. },
  49. {
  50. "name": "tag2",
  51. "address": "1!400004",
  52. "attribute": 3,
  53. "type": 9,
  54. "precision": 3
  55. }
  56. ]
  57. }
  58. ]
  59. }

Response

json

  1. {
  2. //tags count
  3. "index": 4,
  4. "error": 0
  5. }

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

json

  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

json

  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

json

  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

json

  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

json

  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
    • 2303 library name conflict
    • 2304 library open fail
    • 2305 library module invalid
    • 2307 library instance fail
    • 2308 library arch no support
    • 2310 library add fail
    • 2311 library module exist
    • 2313 library module kind no support

Body

json

  1. {
  2. //plugin library name
  3. "library": "plugin_name.so",
  4. // base64 content of schema json file
  5. "schema_file":"...",
  6. // base64 content of library file
  7. "so_file":"..."
  8. }

Response

json

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

Update Plugin

PUT /api/v2/plugin

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK

  • 400

    • 2302 library no found
    • 2302 library info invalid
    • 2304 library open fail
    • 2305 library module invalid
    • 2307 library instance fail
    • 2308 library arch no support
    • 2312 library module no exist
    • 2313 library module kind no support

Body

json

  1. {
  2. //plugin library name
  3. "library": "plugin_name.so",
  4. // base64 content of schema json file
  5. "schema_file":"...",
  6. // base64 content of library file
  7. "so_file":"..."
  8. }

Response

json

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

Del Plugin

DELETE /api/v2/plugin

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK

  • 400

    • 2306 library of system no allow delete
    • 2309 library in using

Body

json

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

Response

json

  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

json

  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

json

  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

json

  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

json

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

Subscribe Multiple Groups

POST /api/v2/subscribes

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2106 group not exist

Body

json

  1. {
  2. //app name
  3. "app": "mqtt",
  4. "groups": [
  5. {
  6. //driver name
  7. "driver": "modbus1",
  8. //group name
  9. "group": "group1",
  10. //optional, depends on plugins
  11. "params": {
  12. //when using the MQTT plugin, the topic key is the upload topoic
  13. "topic": "/neuron/mqtt/modbus1/group1"
  14. }
  15. },
  16. {
  17. "driver": "modbus2",
  18. "group": "group2",
  19. "params": {
  20. "topic": "/neuron/mqtt/modbus2/group2"
  21. }
  22. }
  23. ]
  24. }

Response

json

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

Update Subscribe Parameters

PUT /api/v2/subscribe

Request Headers

Content-Type application/json

Authorization Bearer <token>

Response Status

  • 200 OK
  • 404
    • 2106 group not exist

Body

json

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

Response

json

  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

json

  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

json

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

Get Subscribe Group

GET /api/v2/subscribe

Request Params

app required

driver optional, substring match against driver name

group optional, substring match against group name

Request Headers

Authorization Bearer <token>

Response Status

  • 200
  • 400

Response

json

  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

json

  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

json

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

Response

json

  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

json

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

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

json

  1. {
  2. // node name
  3. "node": "modbus-tcp",
  4. // log level: debug, info, notice, warn, error, fatal
  5. "level": "debug",
  6. // whether to switch the core log level
  7. "core": true
  8. }

TIP

The core field is optional and defaults to true.

The node field is optional. If this field is not filled in, the core cannot be false, and only the core log level will be switched.

Response

json

  1. {
  2. "error": 0
  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.

json

  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.

json

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

Put Drivers

PUT /api/v2/global/drivers

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
    • 1002 request body invalid
    • 2010 node name too long
    • 2011 node not allow delete
    • 2105 group parameter invalid
    • 2107 group name too long
    • 2108 reach max number of groups
    • 2304 library failed to open
    • 3013 plugin name too long
    • 3019 plugin does not support requested operation
  • 404
    • 2301 library not found
    • 3014 plugin not found
  • 409
    • 2104 group exist
    • 2202 tag name conflict
    • 2307 library not allow create instance
  • 500
    • 1010 server is busy
    • 1001 internal error

Body

json

  1. {
  2. "nodes": [
  3. {
  4. "name": "rtu template",
  5. "plugin": "Modbus RTU",
  6. "params": {
  7. "param1": 1,
  8. "param2": "1.1.1.1",
  9. "param3": true,
  10. "param4": 11.22
  11. },
  12. "groups": [
  13. {
  14. "name": "group1",
  15. "interval": 2000,
  16. "tags": [
  17. {
  18. "name": "tag1",
  19. "type": 4,
  20. "address": "1!400001",
  21. "attribute": 1,
  22. "precison": 1,
  23. "decimal": 0
  24. },
  25. {
  26. "name": "tag2",
  27. "type": 11,
  28. "address": "1!400009",
  29. "attribute": 3
  30. }
  31. ]
  32. }
  33. ]
  34. }
  35. ]
  36. }

Response

json

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

Get Drivers

GET /api/v2/global/drivers

Request Headers

Content-Type application/json

Authorization Bearer <token>

Request Params

name Optional, list of names to filter out driver nodes (separated by ‘,’)

Response Status

  • 200 OK
    • 2005 node setting not found
  • 400
    • 1003 request param invalid
  • 404
    • 2003 node not exist
  • 500
    • 1010 server is busy
    • 1001 internal error

Response

If success, returns the list of drivers.

json

  1. {
  2. "nodes": [
  3. {
  4. "name": "rtu template",
  5. "plugin": "Modbus RTU",
  6. "params": {
  7. "param1": 1,
  8. "param2": "1.1.1.1",
  9. "param3": true,
  10. "param4": 11.22
  11. },
  12. "groups": [
  13. {
  14. "name": "group1",
  15. "interval": 2000,
  16. "tags": [
  17. {
  18. "name": "tag1",
  19. "type": 4,
  20. "address": "1!400001",
  21. "attribute": 1,
  22. "precison": 1,
  23. "decimal": 0
  24. },
  25. {
  26. "name": "tag2",
  27. "type": 11,
  28. "address": "1!400009",
  29. "attribute": 3
  30. }
  31. ]
  32. }
  33. ]
  34. }
  35. ]
  36. }

otherwise returns the error code.

json

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