15

Code Snippet

Using curl:

$ curl http://stackoverflow.hewgill.com:8080/firehose/stackoverflow

or, in a browser, http://stackoverflow.hewgill.com:8080/firehose/stackoverflow.

About

This "firehose" service repackages the stream provided by the /events service into a form similar to the Twitter Streaming API.

Each event is sent in an individual snippet of JSON. Each snippet is followed by a carriage return (\r) plus one or more newlines (\n). Newlines may be sent periodically between snippets to help keep connections open.

The current average rate of new events from Stack Overflow is less than one per second.

At present, only the stackoverflow event feed is supported. Supporting all SE sites would currently require too many separate API requests to the /events service.

This is mostly intended as a "proof of concept" demonstrating how such an API could be offered; hopefully this sort of streaming service will be available in a future version of the Stack Exchange API.

Platform

This streaming service can be used by any HTTP client that can consume a response of indefinite length. The responses have an Access-Control-Allow-Origin: * header which makes this possible to use in a browser.

Contact

Greg Hewgill

Please let me know if you are using this service, as I may change things that affect users.

Code

This service is written in Erlang using Mochiweb.

13
  • 1
    curl does the trick too: curl http://stackoverflow.hewgill.com:8080/firehose/stackoverflow
    – russau
    Commented Apr 18, 2012 at 23:27
  • @russau: Good idea, a single command example is nicer. Commented Apr 18, 2012 at 23:36
  • @GregHewgill is there any way to get the tags related to the question? Commented Feb 13, 2014 at 15:14
  • 2
    @SarathSaleem: I'm afraid not. The /events service does not return tag information, so a request would need to be made for each question (these can be batched). This is something a client can do if required. Commented Feb 13, 2014 at 17:22
  • @GregHewgill I am writing an application where I want to track the activity of a particular post. For instance, if I post a question, I want to track the answers, comments and votes on that post in real time. Can I use a similar approach to achieve this? Commented Aug 15, 2014 at 20:50
  • @RakeshAdhikesavan: Yes, you could use the firehose to get notifications about all new activity, and throw away everything that does not relate to your particular question of interest. Of course if you're writing your own program, you'll probably want to use the /events interface directly; the stuff I wrote is designed for consumption within a browser. Commented Aug 15, 2014 at 22:51
  • @GregHewgill, Are there limitations to using stackhose? if I run curl stackoverflow.hewgill.com:8080/firehose/stackoverflow , would it stop at some point because of the API's throttles? Commented Aug 23, 2014 at 0:13
  • @RakeshAdhikesavan: No, it won't stop because of a throttle. If you get disconnected for some reason, just reconnect. Commented Aug 23, 2014 at 2:45
  • @GregHewgill: I can't get the link to work right now. There are no updates. Commented Oct 12, 2014 at 20:42
  • @GregHewgill: /events of the API seems to work fine. I just checked. Commented Oct 12, 2014 at 21:06
  • Yes, there seems to be something wrong with my firehose service. I am not in a position to investigate right now. Commented Oct 12, 2014 at 21:07
  • @GregHewgill Could you tell me how to repackage the stream provided by the /events service into a form similar to the Twitter Streaming API ? I would like to try to re-create your service for my purpose, but I don't know where to start .. any help would be great.. Thanks Commented Oct 15, 2014 at 0:26
  • 2
    I fixed the app, it was getting an error authenticating to the SE API due to an expired token or something. Commented Oct 15, 2014 at 7:58

0

You must log in to answer this question.

Browse other questions tagged .