I want to get all the questions under a tag which has at least one answer with 10 or more votes.
I searched the Advanced Search documentation and searched Py-StackExchange's documentation, but I could not find suitable parameters.
I want to get all the questions under a tag which has at least one answer with 10 or more votes.
I searched the Advanced Search documentation and searched Py-StackExchange's documentation, but I could not find suitable parameters.
The API is very poor for finding results based on answer criteria, despite numerous feature requests.
You can't do this with any of the /answers
routes, and the /search
routes return questions only, and don't provide the search criteria needed.
Your most accurate results can be had with SEDE, like the query Glorfindel provided, but this lags by a week and is not automatable.
BigQuery allows you to automate queries to the data dump, but this data is only updated every quarter.
You can almost do this in the API with the /search/advanced
route and a judicious use of the q
parameter.
For example this API query:
/2.2/search/advanced?q=is:answer score:10&tagged=angularjs
Returns all questions, tagged angularjs, that have one or more answers scoring 10 or greater.
It is roughly equivalent to this advanced search on the live website, except that the website returns answers and the API returns questions. Note that questions often have several answers scoring more than 10. (And qualifying questions usually have other lower-scoring answers too.)
The API results are like:
{
"tags": ["angularjs", "angular-ui-router"],
"answers": [ {
"owner": {"display_name": "apohl"},
"is_accepted": true,
"score": 4,
"link": "https://stackoverflow.com/questions/22233251/default-route-for-angular-ui-router/22235960#22235960"
}, {
"owner": {"display_name": "nottinhill"},
"is_accepted": false,
"score": 15,
"link": "https://stackoverflow.com/questions/22233251/default-route-for-angular-ui-router/27435414#27435414"
}, {
"owner": {"display_name": "Jorge Armando Palm"},
"is_accepted": false,
"score": 6,
"link": "https://stackoverflow.com/questions/22233251/default-route-for-angular-ui-router/29166806#29166806"
},
etc...
],
"is_answered": true,
"view_count": 38211,
"answer_count": 6,
"score": 16,
"last_activity_date": 1509428733,
"creation_date": 1394131433,
"question_id": 22233251,
"link": "https://stackoverflow.com/questions/22233251/default-route-for-angular-ui-router",
"title": "Default route for angular ui router"
} ],
... More questions...
That is, for each qualifying question, all of its answers are listed.
HOWEVER, this approach also restricts the results to questions that have at least 10 upvotes. So it's not exactly what you want, but most questions that a 10-score answer, tend to have 10+ votes too, and vice-versa.