6

I've combed through the API documentation and http://dev.sstatic.net/Js/full.en.js but the only method that I've been able to locate to get the number of close votes on a question is to read the response from casting or retracting a close vote. Obviously this is not optimal.

I'm trying to write a bot for the SO Close Vote Reviewers chat room to move close vote requests for questions that have been closed to an archive room. We do this manually right now to keep the transcript size down. I can send a request to retrieve the actual question page and run a search for .existing-flag-count and use the text contained within that element if it exists, but that is a lot of bandwidth for a simple request.

Can we please have a /questions/{id}/close-votes API page? All I want is the number of close votes but if you also wanted to include the close reasons that could be useful for other things.

2
  • 1
    Did you miss /flags/questions/[id]/close/popup?
    – Shog9
    Sep 25 '15 at 0:26
  • That works too. Sorry, should have looked harder. Sep 25 '15 at 1:14
9

You can use the /questions/{id}/close/options method (see the docs for more info).

Feed it a question id (say 32772917 currently on Stack Overflow) and you can get list of close reasons, each with an individual count object telling how many active close votes there are for each reason.

Example response (with only a subset of the whole response shown):

"items": [
{
    "count": 2,
    "has_flagged": false,
    "requires_question_id": false,
    "requires_site": false,
    "requires_comment": false,
    "option_id": 16055,
    "dialog_title": "Why should this question be closed?",
    "description": "Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking.",
    "title": "unclear what you're asking"
  },
  {
    "count": 0,
    "has_flagged": false,
    "requires_question_id": false,
    "requires_site": false,
    "requires_comment": false,
    "option_id": 29650,
    "dialog_title": "Why should this question be closed?",
    "description": "There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.",
    "title": "too broad"
  }
]
1
  • Ahh, totally missed that. I thought it was just for possible options. Thanks. Sep 25 '15 at 1:12

You must log in to answer this question.

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