9

I am really struggling with this one...

Given a user ID, how can I monitor questions that that user has asked for new answers?

I'm worried the solution will look something like this:

  • Get all questions for a given user
  • Get answer_count for each of them
  • Compare each answer_count to the stored number from the last check
  • If any two don't match, then an answer has been added or deleted
  • Repeat at specified interval

Is there a better way?
Is there some way to get all answers posted to a user's questions between a given time span?

3 Answers 3

5

You can use sort=creation and min to pull in only new answers given a list of question ids and the questions/{id}/answer route.

You can do the equivalent with users/{id}/questions to monitor for new questions.

That will let you monitor up to 100 questions a request.

2
  • Kevin: I'm a bit surprised by this, and I have to think it's intentional. Wouldn't one of the MOST COMMON API REQUESTS be "get me all new answers to any of my questions?". I imagine, however, that if a proliferation of notifiers appeared, people would check the sites less, and the community would suffer.
    – Portman
    Commented Jun 26, 2010 at 3:32
  • 1
    Links not working. Commented Jul 2, 2010 at 3:39
1

Just make an API request every few minutes and parse it out then compare it. That's the only way I can think of. Sure it'll be a lot of code, but you gotta do what you gotta do

1

I think polling with /users/{id}/questions is the best option here. I don't think you have to compare the answer_counts though. You could try the fromdate param on the api call, and just save the time of the last request. Then anything in the response must be after that time and therefore new.

1
  • Does fromdate only return questions with new answers? Otherwise it won't work. Commented May 26, 2010 at 4:34

You must log in to answer this question.

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