npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stream-tweets

v1.1.0

Published

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

Downloads

7

Readme

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