POST /nodes

安装新的节点模块

需要权限:nodes.write

请求头

请求头
授权 Bearer [token] - 如果启用了认证
内容类型 application/json - 如果从 npm 仓库安装
内容类型 multipart/form-data - 如果安装 tgz 包

参数

当从 npm 仓库安装包时,请求体必须是一个 JSON 字符串,包含以下字段:

字段 描述
模块 要从 npm 仓库安装的节点模块的名称,或者是包含节点模块的目录的完整路径。注意:此 API 不支持 npm 使用的全部模块规范符,例如 .tgz 文件或版本限定符。
{
  "module": "node-red-node-suncalc"
}

如果安装 tgz 包,请求体必须是 multipart/form-data

以下 curl 示例将安装 node-red-contrib-foo

curl -X POST https://:1880/nodes -H "Content-Type: multipart/form-data" -F "tarball=@node-red-contrib-foo-1.0.3.tgz;type=application/x-compressed-tar;filename=node-red-contrib-foo-1.0.3.tgz"

响应

状态码 原因 响应
200 成功 一个节点模块对象。参见响应体示例
400 请求无效 错误响应
401 未授权
404 未找到
{
  "name": "node-red-node-suncalc",
  "version": "0.0.6",
  "nodes": [
    {
      "id": "node-red-node-suncalc/suncalc",
      "name": "suncalc",
      "types": [
        "sunrise"
      ],
      "enabled": true,
      "loaded": true,
      "module": "node-red-node-suncalc"
    }
  ]
}