Access to Incoming Links via REST API?

Hi folks,

when you navigate to a page in Confluence and view its information (i.e. click on the three dots and then on “Page Information”) you can see which other pages/content link to it, called “Incoming Links”.

Is this info something that is also available via the REST APIs? I’ve over the Content APIs and have been playing around with them but can’t seem to find that field anywhere, including expand fields.

Am I missing something?

Thank you.

2 Likes

Hi @tgriffo,

Welcome to the community!

AFAIK, there’s no way to get these information through the REST API. I tried expanding several fields but wasn’t able to get the information.

Cheers,
Anne

Hi Anne,

Same as my findings.

Thanks very much for giving it a try, I appreciate it! And thanks for the welcome, I’m happy to be here.

Cheers,
Tiago

Hi @tgriffo,

No worries! Glad to help. I’ll just mark the answer as solved so other developers may find it helpful.

Cheers,
Anne

You can get incoming and outgoing links of a page using the Relation REST API https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-relation/

Hi lassenza,

thanks for that link, it pushed me in the right direction. I’m just missing a little piece of information now :wink:

The API endpoint looks like that:

/wiki/rest/api/relation/{relationName}/from/{sourceType}/{sourceKey}/to/{targetType}/{targetKey}

So I think I would do

...relation/{relationName}/from/content/123456/to/content/45678

But I have no idea, what relationName to use. Do I have to create the relationship manually? I would guess it’s created automatically when linking the pages…

Thanks in advance :wink:

Hi @PatrickHilgarth, yeah the documentation is not particularly clear.
The relationName should be link.

So, for example, to get incoming links to page 123456 the endpoint would be:
wiki/rest/api/relation/link/to/content/123456/from/content?expand=source

Instead, for outgoing links from the same page the endpoint would be:
wiki/rest/api/relation/link/from/content/123456/to/content?expand=target

Hi @lassenza - unfortunately this does not work, my url looks like that:

http://localhost:1990/confluence/wiki/rest/api/relation/link/to/content/950276/from/content?expand=source

Any more ideas? I fear, that it’s simply not possible to fetch this data via the API…

I get an 404, when trying it:

image

So you are using server. I thought you were using cloud.
For server I don’t think there is any REST API for getting incoming/outgoing links.
But you can use the Confluence API.

For example for retrieving incoming links you could use LinkManager.

For outgoing links you could use OutgoingLinksExtractor

I still were on my local environment, where I got the 404.

On our cloud platform however, I get a result. Unfortunately, it’s just an empty array. Am I missing something here? See my code and the output in the forge tunnel:

Have you tried /rest/api/relation/link/to/content/${contentId}/from/content?expand=source instead of /wiki/rest/api/relation/link/to/content/${contentId}/from/content?expand=source ?

Hi,
Did anyone manage to get some results?
I too get an empty array.
Thanks

I’m looking for a solution to this as well.
I too get an empty array:
image

Hi,
Same here, as result I get an empty array only.
Has anyone managed to find out the backlinks?

@AlexanderMartin @BertDombrecht @MatteoGubelliniSoftC @PatrickHilgarth,

Please open a new topic. This question was initially asked in Confluence Cloud with some people later asking about Confluence Server. The products are quite different in their REST APIs, if not internal workings. So, with this topic having been “solved”, we need a new question in the category appropriate to your problem. Otherwise, I fear this topic won’t get any new answers.