2

Currently with the SE api, you can get all the answers on a specific question using /question/ID/answers. You can also get all the answers by a specific user on a post using /users/ID/answers.

The problem is I don't see anyway to get all the answers on a specific question by a specific user.

I do know that I can filter the api response but my target question is the PPCG sandbox in which there are much more than a 100 questions meaning I could possible have to do up to 19 requests to get all the answers considering the maximum page size is 100.

4

The closest thing that could work is using the Excerpt Search.

It is a little bit hacky because you have to select the question based on its full title but you can restrict the search_excerpts's that get returned to a single user.

search form on api

Here is a code snippet that demonstrates how you can use that call and process its results.

var url = ['https://api.stackexchange.com/',
           '2.2',
           'search',
           'excerpts'],
    query = [ 'order=desc', 
             'sort=activity',
             'title=Sandbox%20for%20Proposed%20Challenges',
             'user=40695', 
             'site=meta.codegolf'],
    api = url.join('/') + '?' + query.join('&');

$(document).ready(function () {
  $.get(api, function(data) {
    var i, item;
    for(i = 0; i < data.items.length; i = i + 1) {
      item = data.items[i];
      $('#result').append(      $('<tr></tr>').append(
          $('<td></td>').append(
           $('<a></a>')
            .prop('href', 'https://meta.codegolf.stackexchange.com/a/' + item.answer_id)
            .text(item.answer_id)
          ),
          $('<td></td>').text(new Date(item.creation_date*1000).toDateString()),
          $('<td></td>').text(item.score)
        )
      );
    }
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="result">
  <tr><th>answer</th><th>created</th><th>score</th></tr>
</table>

| improve this answer | |
  • Thanks for the answer, +1, but it doesn't look like search_except returns all the data I need (body_markdown to be specific). In the meanwhile I'll just set the page_size to 100. – Downgoat Jan 17 '16 at 20:11
  • 1
    @Downgoat No, but you can do a second call then to retrieve those, so you're down to two calls then and with a bit of luck no paging – rene Jan 17 '16 at 20:13

You must log in to answer this question.

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