Is there an API to control Node-RED

I was wondering if there is a way to add, delete, connect nodes inside Node-RED from an outside source without the GUI.

For example from the command line or some kind of requests that I can use in my programming language.
An API that will give me access to controlling the dashboard, connecting nodes and more.

I'm working on a smart home platform named CyBear Jinni and want to use Node-RED as scenes and automation platform-control and management.

Basically I have imagined inserting new nodes and blocks from my program, fill them with info, connecting them to one another with logic.
My program will insert and listen to MQTT changes and will get updated about the output of requests.

Whenever I get a new smart device at home I will be able to add this device to the dashboard and connect it programmatically to all the correct scenes that my program created beforehand.

I will create an MQTT path and values for everything so that Node-RED be able to interact with it.
For example a Tuya device does not use MQTT, but my program speaks with it through their API and exposes/publishes their values inside an MQTT path.

And vice versa, when my program detects changes in the MQTT path of a Tuya device it will synchronize it with the device by sending the new state/action to it with its API.

You can say that one of my program purposes is exposing and connecting everything with MQTT, and I want Node-RED to contain the logic of my program.

I want that my program users will be able to open Node-RED and check out and interact with the automation that my program created for them.

Another reason that I have chosen Node-RED is the number of options and tools that it could grant out of the box or with downloading new nodes and plugs.

The Runtime provides an HTTP Admin API - which is what the editor uses - that lets you update the flow configuration. You have to construct the appropriate JSON yourself, but you can then give it to the runtime.

https://nodered.org/docs/api/admin/methods/post/flows/

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.