I am coding an application that notifies events in Stack Exchange accounts. I want to notify about badges/reputation changes, and also I would like to notify whenever a new answer or comment is posted (to the user's own questions and the questions he flagged as favourites)

About the "questions activity", I think i can use the API in two ways to achieve it, but i am not sure which one would be better in order to minimize the impact on the servers.

Option 1:

  • Read questions (using /users/{ids}/question) with activity changes since last update (using "min" parameter), without receiveing all the the data ( answers=false&comments=false )
  • Read favourites (users/{id}/favorites) with activity changes since last update. (Parameters the same as above)
  • Read timeline for those questions (/questions/{ids}/timeline) since last update time. (using an array
    with all the questions in order to receive the updates in one single API call). This call is ommited if there aren't any questions with activity in the selected period.

Option 2:

  • Read all questions with activity changes since last update , including answers and comments (answers=true & comments=true and using "min")
  • Read all favourites with activity changes since last update , including answers and comments (answers=true & comments=true and using "min")

Option 1 requires more API calls, but it drastically reduces the amount of data received for every call. With option 2, i can reduce the API calls, but the amount of data transferred increases a lot. (and in some tests i did, it takes much longer time because of the amount of data involved)

Reviewing the API usage questions, i think both options comply with the guidelines. The polling period is user configurable, but I don't allow it to be less than two minutes. With that period, the app would not go anywhere near the 10K daily limit. Also, i am waiting at least 5 seconds between API calls, in order not to make very consecutive calls to the API.

Which option would be better, in terms of API usage?

1 Answer 1


Notifications for new answers are quite easy. Here's what I did for StackApplet:

  • Grab the users' recent 100 questions (the maximum) with no body or anything
  • Combine the IDs using ';' and make the following query:

    http:// {site} /1.1/questions/ {combined_question_ids} / answers?fromdate= {time_of_last_poll}

    What this is essentially doing is grabbing all answers posted since the last query for the 100 question IDs provided. This will catch 99% of all new answers.

  • Thanks for your answer. That's also the way i am doing it right now in my tests. The difference is that i use the timeline, in order to get comments and revisions. My concern is not how to do it, but knowing which option is best in order not to overload the API servers or get bad usage warnings.
    – ernie
    May 18, 2011 at 9:52
  • @Ernie: This way uses only 2 requests. May 18, 2011 at 15:09

You must log in to answer this question.

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