SOS,How to control a node by code (add node,update node,delete node)

help me! I`m learning red-node recently, i want to know hao to control node and flow by using code (add,delete,update)

Hi.

Welcome to Node-red.

The idea of creating a "flow" (that's what a program is called in Node-red) is just a case of putting the nodes on the screen and connecting them.

Ok, here's a basic one:

From the left of the screen scroll and find the inject node.
Drag it to the middle area of the screen.
It will be there and a little dot on it. Don't worry for now.
Double click the node and change it from saying timezone to string and then enter some text in the area to the right.
Click OK.
Then on the left of the screen, scroll down a bit and find the debug node.
Drag it to the middle area of the screen where you put the inject node.
Not on top of it, but not too far away.
Say a bit to the right.
Then move the mouse over the inject node and on the right side of the node, you will see a small circle.
When you put the mouse over it, you will see it turns orange - the circle that is.
Press the mouse button (and hold it) and move to the debug node on the left side where you see another little circle.
Like with the inject node, when you get over the circle, it will turn orange.
Release the mouse button and you have connected the two nodes together.

You should see a line between them.

All being good, in the top right there is a big red button marked DEPLOY.

Press it and wait.

Just down from there there are 3 or 4 little buttons.
Info, Debug and ..... They look like an 'I' and a little bug on their buttons.

Press the one with the bug on it.

Now go over to the inject node and on the left side there is a "tab" sticking out.
That is the "button" you press to inject the message.

Press it and you should see what you entered appear on the right of the screen.

That is basically how node-red works.

Here are the pictures to maybe help you with what I said:
The inject node is opened and I change the RED box to text (as shown) and enter the "message" as shown in GREEN. Then I press the DONE button. (Blue)

The next is the button you press (blue) and the debug node (green)
You can see the message on the right of the screen.
The red box is where the buttons are which you need to press for the debug mode to see the message.


thanks a lot , but that can't help me

what i want to know is how to control node by using code in function node and import json of flow by using code in function

Have you found the API documentation?

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

1 Like

thank you ,i will try it