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 🙏

© 2026 – Pkg Stats / Ryan Hefner

twit-old

v0.1.3

Published

Twitter API client for node (REST & Streaming)

Readme

#twit

Twitter API Client for node

Supports both the REST and Streaming API.

#Installing

npm install twit

##Usage:

var Twit = require('twit');

var T = new Twit({
    consumer_key:         '...'
  , consumer_secret:      '...'
  , access_token:         '...'
  , access_token_secret:  '...'
});

//
//  tweet 'hello world!'
//
T.post('statuses/update', { status: 'hello world!' }, function(err, reply) {
  //  ...
});
      
//
//  search twitter for all tweets containing the word 'banana' since Nov. 11, 2011
//
T.get('search', { q: 'banana', since: '2011-11-11' }, function(err, reply) {
  //  ...
});

//
//  stream a sample of public statuses
//
T.stream('statuses/sample', function (stream) {
   stream.on('tweet', function (tweet) {
     console.log(tweet); 
   });
});
      
//
//  filter the twitter public stream by the word 'mango'. 
//
T.stream('statuses/filter', { track: 'mango' }, function (stream) {
  stream.on('tweet', function (tweet) {
    console.log(tweet);
  });
});

twit API:

Just 3 methods. They cover the full twitter API.

  • T.get(path, [params], callback) GET any of the REST API Endpoints.
  • T.post(path, [params], callback) POST any of the REST API Endpoints.
  • T.stream(path, [params], callback) Use this with the Streaming API.

Note: Omit the .json from path (i.e. use 'statuses/sample' instead of 'statuses/sample.json').

Using the Streaming API

T.stream() keeps the connection alive, and passes a stream object to callback.

stream is an EventEmitter that emits the following 4 events:

  • tweet status (tweet)
  • delete status (tweet) deletion message
  • limit limitation message
  • scrub_geo location deletion message

If you want to stop the stream, emit the 'stop' event: stream.emit('stop').

To restart the stream, emit the 'start' event: stream.emit('start').

###path

  • If path is 'user', the User stream of the authenticated user will be streamed.
  • If path is 'site', the Site stream of the authenticated application will be streamed.
  • If path is anything other than 'user' or 'site', the Public stream will be streamed.

#What do I have access to?

Anything in the Twitter API:

  • REST API Endpoints: https://dev.twitter.com/docs/api
  • Public stream endpoints: https://dev.twitter.com/docs/streaming-api/methods
  • User stream endpoints: https://dev.twitter.com/docs/streaming-api/user-streams
  • Site stream endpoints: https://dev.twitter.com/docs/streaming-api/site-streams

Go here to create an app and get OAuth credentials (if you haven't already): https://dev.twitter.com/apps/new

#How do I run the tests?

Clone the repo

git clone [email protected]:ttezel/twit.git

Install the dev dependencies (mocha and should):

npm install mocha -g should

Note: When the -g flag is invoked, the package will be installed globally. In order to use mocha from the command line, you must use the -g flag.

Create a config.js file in the root of the cloned repo. It should export the oauth credentials. It should look something like this:

module.exports = {
    consumer_key: '...'
  , consumer_secret: '...'
  , access_token: '...'
  , access_token_secret: '...'
}

Then run the tests with mocha:

mocha -t 10000 tests/*

You can also run the example:

node examples/rtd2.js

iRTD2

The example is a twitter bot named RTD2 written using twit. RTD2 tweets about github and curates its social graph.


License

(The MIT License)

Copyright (c) by Tolga Tezel [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.