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

streaming-twitter

v0.0.1

Published

Streaming API for Twitter.

Downloads

14

Readme

twitter-js

JS Implementation for the Twitter Public Streaming API.

The Fun Stuff

Build Status

Code Climate

Issue Count

Test Coverage

Dependency Status

npm Version

Getting Started

First you need to create a TwitterPublicStream

var twitter = require('twitter');
var myTwitter = new twitter.TwitterPublicStream({
	consumerKey : 'your consumer key',
	consumerSecret : 'your consumer secret',
	accessToken : 'your access token',
	accessTokenSecret : 'your access token secret'
});

Then you can setup listeners for the callbacks

myTwitter.on('connected', function(response){});
myTwitter.on('heartbeat', function(){});
myTwitter.on('close', function(reason){});
myTwitter.on('error', function(errObj){});
myTwitter.on('garbage', function(buffer){});
myTwitter.on('data', function(data){});
  • Connected : Called when connected, allows you to start tracking terms

  • Heartbeat : Called when no data has passed for a while, to keep the connection alive

  • Close : Called on close, with the reason

  • Error : Called when there is an error, with an error object. This has a type and data property

  • Garbage : Called when the response can not be parsed as JSON, provides the buffer from twitter

  • Data : Called when a tweet is parsed from the stream. Provides the Tweet as JSON.

Tracking a term

You can use this to filter and track specific terms. Just provide a comma delimited list of terms to track (e.g. '#obama,#hillary'). This then goes into the track() method as so:

myTwitter.track('#obama,#hillary');

Changing a term

To change the list of terms, call stopTracking(), then recreate the stream. Sadly this is a Twitter restriction, that doesn't allow you to change a stream.

myTwitter.stopTracking();
myTwitter.track('#clinton');

Questions?

Just ping me at:

hacker (a) maddhacker dot com

Enjoy!

Getting Started

  • Install the npm in your project: npm install --save streaming-twitter
  • Require the library where needed: const twitter = require('streaming-twitter');
  • Stream Twitter.

Slack

This is one of several projects that are in the works, so feel free to reach out on Slack. Please email slack at maddhacker dot com for an invite.

Issues

Please use the Issues tab to report any problems or feature requests.

Change Log

All change history can be found in the CHANGELOG.md file.