I need to find the total number of answers submitted by a user on stackoverflow. I tried the following:

I got my json from the following:


To get the total number of answers by the user_id I did:


This however always returns me 30 if the number of answers by the user_id is more than 30. Is there a way I can get the actual number of answers by the user?

The documentation says that users/user_id/answers/ should return the list of all answers by the user

2 Answers 2


It does return all the answers, but they're paged - by default you'll only get 30 at a time. You'll likely want to increase pagesize to 100, and then add the additional code necessary to make subsequent requests if has_more is set on the response wrapper.

So, for example, your first request would be like


and if the response had had_more you'd need to request


and so on until has_more returns false. Be careful about requesting too quickly or you'll be throttled.

  • thanks a lot Tim! Can you also add how should the url be with the 'page_size' option. Commented Dec 11, 2014 at 14:57

If you just want the total, don't bother paging through the entire full result set.
Use the total property of the Common Wrapper Object. This will save lots of time and bandwidth and quota and doesn't require you to loop through the results just to count things.

The total property is not enabled by default, so you will need to Create a custom filter for your queries. (You should do this anyway, to speed your app up.)

Here's how it looks for that /users/{ids}/answers route:

Which currently yields:

  "has_more": false,
  "quota_max": 10000,
  "quota_remaining": 9993,
  "page": 1,
  "page_size": 30,
  "total": 41,
  "type": "answer"

Unfortunately, the API does not do subtotals. So if you fetch more than one user at a time, this streamlined method will not work. (EG: this two-user request yields total = 3663 (at least 37 pages of answers) with no way to tell which user has which without paging through your original-style query.)

  • Thanks Brock for the tip :) . Actually I also wanted to filter total number of accepted answers and unaccepted answers. Is there a short way to get this too? I am currently checking each answer and its is_accepted' key for this. Commented Dec 12, 2014 at 18:42
  • Unfortunately no. API support for answer-search is still spotty and buggy. To determine how many answers are accepted or not, you must page through, as you are currently doing, or you can scrape the normal search page and parse the results display at the top. Commented Dec 12, 2014 at 22:22

You must log in to answer this question.

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