Skip to main content
1 of 2
Enlico
  • 197
  • 6

Obtain the list of questions associated to answer_ids without loosing the information of which question comes from which answer_id

This is a follow up to a previous question of mine, and the starting point is that, given a list of reputation objects retrieved via /users/{ids}/reputation, I can easily retain only the entries with post_type == 'answers' and then get post_id for each of them, ending up with a list of answer_ids.

Given this list of answer_ids, how can I efficiently obtain the list of question objects associated to those answer_ids without loosing the information of which question comes from which answer_id?

Clearly, I could make one /answers/{ids}/questions request for each of the answer_ids, but this means... I'm being kicked out with a 503 (Service unavailable) (hence the ta).

On the other hand, making one single /answers/{ids}/questions request for all the ids (well, I should actually make a request for chunks of 100 entries; then maybe I have to browse the few resulting pages; but this probably still means a small number of requests), I'm a bit unsure about whether those questions are obtained in the same order as the the answer_ids. Quite the opposite, from this answer I understand that there's no guarantee at all that that's the case.

If the retrieved questions are not sorted as the answer_ids, then the only way I see to re-estabilish the relation is to make a /answers/{ids} request as well (again, in chunks of 100 entries, ...), so that I can recognize which question corresponds to which answer_id, as the question_id is both in questions and answers.

But this looks a bit a convoluted approach. Plus, retrieving the whole answer objects when all I need is the question_id for each of them seems overkill.

Is there any other strategy I could adopt? Or is the latter one I described (retrieving all questions and all answers from the answer_ids) just fine?

Enlico
  • 197
  • 6