Skip to main content

I was using GET/v1/files/:key/nodes endpoint with id param and value I360:21745;1269:159559 to retrieve node data . But the response was just empty array in children attribute in the Page Node where the targeted node exist.


{ "id": "360:10850", "name": "Page 5", "type": "CANVAS", "children": [] ... }


But when I tried to get the node with id 360:10850, it was fine and the node I360:21745;1269:159559 was in the response as well.


How can I get the data for node with id I360:21745;1269:159559? Is there something I should change in my request?

Prefix I means this node is nested within an instance. I see no reason for it not to be returned but from your description it seems like instance sublayers are not returned with this method for some reason. I would try to get the parent instance if possible and then process its children nodes. I don’t have any other ideas.


Yeah. I think that will do for now. Thanks.


Hi @Gleb, do you know if there is a way that RESTAPI can return the parent instance info or id from the nested nodeId I360:21745;1269:159559? right now i am just trimming it to remove the prefix I but it’s not official.


Like in plugin API they have the parent value plugin api but I wondered if there is a way to achieve in RESTAPI. Thanks 🙂


How are you getting the original ID? The only way I can think of if you don’t have parent ID is to fetch the whole file and find the node, then backtrack to its parent.


Thanks for sharing @Gleb 😀 . Yeah for the original instance ID, I am also getting it from fetching the whole file. For instance, I will try to find the nodes with type === 'Rectangle' to find their node.id and commenting on them (using recursive functions to examine all node.children). Some nodes I found could potentially be instance nodes.


Could you also share/explain a bit more about the backtrack? Thank you


Use basic recursive depth-first search algorithm.


One thing you can do it save any instance node you encounter in a variable outside of the search scope. Then if you encounter the node you are searching for, you have its instance parent saved and you have the node, now you can do whatever you want with it.


Another alternative is when you encounter an instance node in the recursive function, keep looking through its children an if you encounter the node you are searching for, return it from the recursive function to get the value back to the scope of the function where you found the instance, then process both as necessary. That’s what I mean by backtracking. Here is a good primer: Backtracking Algorithm - GeeksforGeeks


Hey @Gleb thank you so much for sharing these. These are super helpful! Appreciated it