2

I want to get only closed questions from /questions of the Stack Exchange API.

I've played around a bit with the filters, and I've come up with something which gives me some JSON like this for each question:

{
      "tags": [
        "c++",
        "opencl",
        "intel"
      ],
      "close_vote_count": 0,
      "title": "Weird OpenCL calls side effect on C++ for loop performance",
      "body": "<p>I'm working on a C++ project using OpenCL. I'm using the CPU as an OpenCL device with the  <a href=\"http://registrationcenter.intel.com/irc_nas/5193/intel_code_builder_for_opencl_2015_ubuntu_5.0.0.43_x64.tgz\" rel=\"nofollow\">intel OpenCL runtime</a></p>[...]"
    },

Now, I want only questions which are closed.

How can I do this ?

(another thing: How could I exclude closed questions from the results ?)

Jonas Czech
  • 12,018
  • 6
  • 44
  • 65

1 Answers1

1

You can easily do this by using the following query:

SELECT count(*)
FROM Posts
WHERE ClosedDate IS NOT NULL

This however does not tell you the reason for the closure, to obtain this you should look into the PostHistoryTable which contains detailed information on all changes related to a post.

DJanssens
  • 17,849
  • 7
  • 27
  • 42
  • I want to do this via the API, and not through the data explorer, which kind of hard to use as a data source for an app. But thanks anyway for your answer. – Jonas Czech Jul 07 '15 at 13:41
  • I'm not aware on how to get the count value while using the API, but you could use https://api.stackexchange.com/docs/advanced-search#order=desc&sort=activity&closed=True&filter=default&site=stackoverflow&run=true to get all closed questions. Perhaps that helps? – DJanssens Jul 07 '15 at 14:08
  • I have done this using the advanced search, as per your link. Thanks for your answer, as I did kind of do it with a combination of SEDE and the Advanced Search api in the end. – Jonas Czech Jul 09 '15 at 11:50