Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-tweets

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-tweets

A Node module that uses the Twitter API to stream Tweets in real-time

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

stream-tweets

A node.js module for streaming Tweets live using the Twitter streaming API's

Build Status

Install

npm install stream-tweets

Set Up

Include the module in your code: var StreamTweets = require('stream-tweets');

Create a file (if you haven't already), for your API keys, and add your Twitter credentials in there.

module.exports.twitterKeys = {
    consumer_key :      'XXXXXXXXXXXXXXXXXXXXXXXXX',
    consumer_secret :   'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    token:              'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    token_secret:       'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
};

Include your Twitter keys module, and create a new instance of stream-tweets

var credentials = require('./config/api-keys').twitterKeys;

var st = new StreamTweets(credentials);

Done, now ready to strart streaming!

Basic Usage

This code will continue returning a live stream of all Tweets containing the word 'JavaScript', in real-time.

st.stream('JavaScript', function(results){
    console.log(results); // Do awesome stuff with the results here
});

Stream by location

This example will return a live stream of real-time Tweets from San Fransisco.

st.stream({locations: [-122.75,36.8,-121.75,37.8]}, function(results){
    console.log(results); 
});

You can also select Tweets from multiple locations, just by listing more latitudes and longitudes in the array.

More Streaming paramaters

All the options listed on the official Twitter streaming API documentation are availible in this module.

The Output

By defualt stream-tweets will return just the usefull stuff. An example output will follow this format:

{ date: 'Sun Sep 13 08:48:18 +0000 2015',
  body: 'RT @jsconfasia: Princiya Sequeira; loves JavaScript and can hack D3.js to death! Read more about Princiya on http://t.co/3phJjnObkr http://�',
  location: { geo: null, coordinates: null, place: null },
  'retweet-count': 0,
  'favorited-count': 0,
  lang: 'en' }
{ date: 'Sun Sep 13 08:48:19 +0000 2015',
  body: 'nodenow: Who likes late night coding? #developer #java #javascript #code #coding #programming #adwords #api� � http://t.co/rvoRGmj9Zx',
  location: { geo: null, coordinates: null, place: null },
  'retweet-count': 0,
  'favorited-count': 0,
  lang: 'en' }
{ date: 'Sun Sep 13 08:48:22 +0000 2015',
  body: 'RT @_ericelliott: Advanced Performance Audits with DevTools: http://t.co/UaPoJEFNo0 by @paul_irish #js #JavaScript',
  location: { geo: null, coordinates: null, place: null },
  'retweet-count': 0,
  'favorited-count': 0,
  lang: 'en' }

You want the full output returned by Twitter? No problem! Just set the second paramater to false when creating an instance of StreamTweets. Like this:

var st = new StreamTweets(credentials, false);

Building

stream-tweets uses Gulp to prepare all files

  • gulp build - Lints and compiles all CoffeeScript into JavaScript
  • gulp test - Run unit and coverage tests
  • gulp - Watches files for changes, cleans working directory, builds project and tests then continues watching

See gulpfile.js for full documentation

Testing

npm test

After tests are run, see reports directory for full and detailed test reports.

Veiw the Continuous integration testing report on Travis

Mocha, Chai, Istanbul, Sinon.js, MochaAwesome and Travis CI have been used in the test environment

License

MIT (C) Alicia Sykes

View full license

Keywords

FAQs

Package last updated on 18 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc