0

I know that you could technically loop through the answers returned when you ask for /questions/{id} to see if an answer has been accepted, but it would be AWESOME if there was a top level boolean hasAccepted or something of that nature. How bout it, guys?

2 Answers 2

3

There is "accepted_answer_id" for questions method. When there is no accepted answers,that field does not exists in returned JSON. So hasAccepted is the existance of "accepted_answer_id" field.

0
1

I am facing the same difficulty with API v3.

Let's say I have a set of 1000 questions, and I want to obtain all accepted answers for that set of questions.

I do not see an accepted_answer_id field in my api/v3/questions query results (see this post). As a result, I use the following approach:

  • Iterate through each question in the set
    • Get all answers for this question (api/v3/questions/{question_id}/answers)
      • If an answer has isAccepted == True, remember it for this question

but this is very slow for large (1000+) question sets.

A faster solution might be a combination of the following:

  • Fix/enhance API v3 to return the accepted_answer_id field in question queries.
  • Support some way to bulk-retrieve answers by ID (e.g., api/v3/answers/...)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.