There is an undocumented function app.metadataCache.getBacklinksForFile but if you reverse-engineer it, you find that it iterates through every cached file and its links to find if they reference the desired file.
This logic seems to be unnecessarily inefficient but it seems that it is fast enough so the lag is not noticeable in the Backlinks pane.
However if you need to calculate backlinks programmatically via API in the loop, the inefficiency pays back.
I see no reason why we don’t store a static backlinks cache with O(1) efficiency?
I would love to hear the feedback from the Obsidian dev team with some insights for the decision made.
In the meantime I am planning to develop a plugin with such functionality.