Natural Pacifist Manatees
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

twitter-sentiment

1.1.0 • Public • Published

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

install

npm i twitter-sentiment

Downloadsweekly downloads

2

version

1.1.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar