1

I am trying to get the related questions' IDs of a question.

So let say the question ID I am seeing now is "1" and I want the ID numbers of all the related questions on the sidebar.

3

This information is not available in SEDE (unlike the Linked Questions which are stored in the PostLinks table).

Fortunately, we have jQuery. Open the Developer Tools of your browser, go to the Console and enter the following JavaScript:

$(".sidebar-related").find("a.question-hyperlink").each(function() {
    console.log(/\/questions\/(\d+)\//.exec($(this).attr("href"))[1]);
});

For this question, it returns the following IDs:

7046
7931
20473
29508
60104
87198
170636
203931
258046
258943

| improve this answer | |
0

You can use the Stack API for that.

The endpoint /questions/{ids}/related returns the related question list.

For this question you would use the following link:

questions/293458/related?order=desc&sort=activity&site=meta&filter=!w-1xWerkm*L5vaQIU-

which returns, roughly, this:

{
    "items" : [{
            "last_activity_date" : 1487868137,
            "question_id" : 7931,
            "link" : "https://meta.stackexchange.com/questions/7931/faq-for-stack-exchange-sites",
            "title" : "FAQ for Stack Exchange sites"
        }, {
            "last_activity_date" : 1480040779,
            "question_id" : 7046,
            "link" : "https://meta.stackexchange.com/questions/7046/getting-attention-for-unanswered-questions",
            "title" : "Getting attention for unanswered questions?"
        }
      // left out some results
    ]
}

I leave it to the reader to parse that into a format for your purpose.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .