twitter-sentiment
v1.1.0
Published
Node readable stream to track twitter sentiment via the streaming endpoint
Downloads
4
Readme
twitter-sentiment
Node readable stream to track twitter sentiment via the streaming endpoint
##Installation
npm i twitter-sentiment
Set environment variables for your twitter app (create on Twitter):
export TWITTER_CONSUMER_KEY="..."
export TWITTER_CONSUMER_SECRET="..."
export TWITTER_CONSUMER_ACCESS_TOKEN="..."
export TWITTER_CONSUMER_ACCESS_KEY="..."
##Usage
const twitterSentiment = require('twitter-sentiment')
const Writable = require('stream').Writable
const readable = twitterSentiment({ track: 'clinton', minFollowers: 10000 })
readable.pipe(new Writable({
objectMode: true,
write(chunk, enc, next) {
console.log(chunk.text)
console.log(chunk.sentiment.score)
next(null)
}
}))
// to end the twitter stream connect, emit destroy
readable.emit('destroy')