twit-stream
A simplification for reading Twitter data using Node.JS Streams. Pass in OAuth info and select Twitter stream method, and get a Node stream2 returned. Choose whether you want a stream of objects (objectMode: true) or a stream of buffers.
Usage and Installation
npm install --save twitter-stream
var Twitter = ; var options = consumer_key: '' consumer_secret: '' oauth_token: '' oauth_secret: ''; var stream = options; stream;// Where objectHandler is an arbitrary write stream
See more examples
Stream Endpoints
See information about the different end points on the Twitter Developer site
API
new Twitter(options)
Parameter: option
is object of options.
Returns: Twitter
instance
Options must contain OAuth info
In addition to OAuth data, options allow you to define if the returned streams should be in objectMode or not.
options.objectMode
Type: Boolean
Default: true
With object mode the data passed is a stream of Twitter objects.
By setting the objectMode
to false, the streamed data is a
stream of buffered strings, one tweet buffered up at the time.
objectMode: false
could be used to pipe twitter data directly
to file or to any other write stream requiering buffers.
.filter(data)
Parameter: data
is request payload values (POST body) as documented by Twitter dev site.
Returns: Stream
(with objectMode: true)
.sample(params)
Parameter: params
is values as documented by Twitter dev site
Returns: Stream
(with objectMode: true)
.firehose(params)
Parameter: params
is values as documented by Twitter dev site
Returns: Stream
(with objectMode: true)
Note: You need special premissions by Twitter to have access to the firehose endpoint.
Examples
optionsobjectMode = false;options // pipe to file ;