1.1.0 • Published 8 years ago

twitter-sentiment v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

twitter-sentiment

Node readable stream to track twitter sentiment via the streaming endpoint

npm.io

##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')