How to get backlinks for a file?

Hi, I would like to develop my own plugin, based on that request :point_down: since I also would love to see something like this implemented.

I noticed it is possible to get links with:

const links =;

So half of the job is done. But is there a way to get backlinks?

I kinda don’t want to iterate over whole vault since there is already a backlinks official plugin, so I assume optimal solution is already made.
Like I could just look at official plugin source code and continue from here, couldn’t I? :eyes:

I noticed there is answer to similar question. Even though it is said here that getBacklinksForFile is not documented officially, I couldn’t find it in Typescript typing definitions.

I also think I could just take both “Backlinks” and “Outgoing links” html content and put it inside one tab, but it’s not that fun.

So to sum up: is there a viable way to find backlinks for the current file? If not, what possible workaround?

1 Like

It not being documented means that it’s not found in the typings.
You can test the code in the dev tools console to see what it returns.

1 Like

Could you describe what new user experience you’re trying to design. FYI a forward/outgoing links pane was added to Obsidian w/ v0.12.4 as the “Outgoing Links” core plugin.

Hi, I would like to develop my own plugin, too. Its function includes merging all notes linked to this note. Therefore, I need to find backlinks for the specified note.
:face_with_peeking_eye:For now, is there a feasible way to find the backlink of the current file?

It appears that backlink files can be retrieved using the method in the link given above even in the current version.
I wonder why it is not part of the official API :thinking:

Do you know someone who can approve the 2 PRs I just opened?

One fixes line ending inconsistencies, hopefully for good Line endings by mfp22 · Pull Request #115 · obsidianmd/obsidian-api · GitHub

The other adds the type for getBacklinksForFile Add getBacklinksToFile by mfp22 · Pull Request #116 · obsidianmd/obsidian-api · GitHub

There are actually a lot of things that are available in JS but not in TS.

/* [
] */

// ['finished', 'resolved', 'resolve', 'changed']

// Inspecting the prototype and storing as global var `temp4`
/* [
] */

I can see you’ve already been answered on Github. But please do not ping the developers directly for your requests.

Source: Our Code of Conduct related to pinging devs and moderators.

Hi, maybe it’s too late, but let me share my idea here for those who arrive on this page.

Dataview provides an API for plugin developers.
Its syntax is almost the same as DataviewJS.
For example, you can write something like this to display all the backlinks for path.

const dv = getAPI(;
if (dv) {
    let page =; // Dataview page object
    if (page) {
        for (let backlink of page.file.inlinks) {



EDIT: There seems to be another plugin that offers an API for getting backlinks for ALL the TFiles in the vault, while the Dataview API only provides backlinks for markdown files.