4

I am a beginner with the Stack Exchange API. I would like to get a continuous stream of new questions on Stack Overflow so that I can do some number crunching with it.

Do I have to periodically query the /questions endpoint with a time window to get newer questions or is there another publish/subscribe way of achieving this so that I receive the newer questions rather than polling for them?

4

Probably the most cost-effective way is to poll /questions every minute or two. (Results are cached so, polling more than once a minute probably won't do anything but chew up your quota.)

Related: Provide a streaming API instead of forcing API users to poll

Alternatives:

  • You can get real-time notifications by hooking into one of the undocumented WebSockets. Note that the only endpoint that still seems to work is the 155-questions-active one. I can no longer get the Stack Overflow specific endpoints to work on my current setup.
    Since it is active questions, rather than newest, you will need to separately track which questions are really new.
    Also, 155 is network wide, so you would need to check each response to see if it is for Stack Overflow.
  • Hook-into/Scrape the Stack Exchange real-time page and ignore all the questions from sites you are not interested in. Note that I suspect that this page misses questions, but have no evidence of that.
    Also, this information is essentially the same as for the 155-questions-active WebSocket endpoint.
  • Poll one of the RSS feeds. This works best if you are interested only in specific tags.
  • Poll the /events route and filter for questions. This is not subject to 60-second caching.

But the API is designed for automated access in "close enough" to real time. I recommend that you use it and just poll one of the /questions routes (or /search, etc.).

You must log in to answer this question.

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