Can't get file nodes of component instance children

I’ve been using Figma’s REST API to grab the text content from specific nodes in my designs with the following endpoint:
https://api.figma.com/v1/files/${fileKey}/nodes?ids=${nodeId}

I would then be able to extract the actual text content from the characters key:
response.data.nodes[nodeId].document.characters

In dev mode, I could easily get the node-id from the URL while clicking around my design.

However, I’ve noticed that for component instances, the children nodes have the same node-id as the parent, thus making it difficult to extract the exact text that I need.

I’ve tried using the “Node Inspector” plugin to see the internal id but it gives me ids like "I5912:74596;5912:74456" which don’t work with the API endpoint.

Does anyone know how I can achieve this?