API to get subflow as json by ID

I am trying to retrieve the subflow by ID (are even better all the subflows as an array). I have taken a look at the node red APIs available but non suits my need (there is one for retrieving flows but it does not work with subflows) and there is one for nodes but it does give the subflows either.

Is an API for retrieving subflows is planned? If not, what would be the best means to retrieve the subflows.

My use case is that I am trying to dynamically update a dashboard for testing with new subflows when they are created. This consists of updating a dashboard flow automatically using the POST /flow/:id API and injecting an updated json with all the subflows matching a defined condition (name starting with test for instance).

Thank you for your help

All of the subflows are on the flow with an id of global which you can get via the /flow/global end point.

1 Like

Thank you knolleary, this is of great help. I'll let you know if I manage to update my flow integrating my testing subflows.


I am currently using node-red as a test automation solution for connected vehicles. I have designed a set of tests (each test embedded in a subflow) and I am using a dashboard flow integrating the tests subflow which enable me to select the tests I want to launch.

As the number of tests will significantly increase, I am currently willing to automatically modify the dashboard flow in order to add tests that have been designed as subflows (As of now for each test I am obliged to add quite a lot of config in the dashboard (chain the test with the others, add a button to say whether I want to select the test or not for the test bench...). Thanks to some support I have been able to retrieve the subflows using the GET /flow/general API. Yet I dont know how to generate a unique id in the form of 8 hexa char . 6 hexa char to use as custom node (from subflow) id to integrate in the dashboard. What library do you use to generate flow id and node id? Is there another way to achieve what I intend to do?

Ok as for the id, I got the reply by having a look at the source code of node red : (1+Math.random()*4294967295).toString(16)

The IDs can be any string you want - generate a suitably long random string of characters. You don't have to use the same code we do and we may well change how we generate them at some point as the presence of a . can cause issues when using the node id as a key in a database (eg with mongo).