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

twitter-rss-feed

v1.4.0

Published

TwitterRSSFeed: Twitter RSS feed Node.js library

Downloads

9

Readme

TwitterRSSFeed: Twitter RSS feed Node.js library

npm version

Installation

$ npm install twitter-rss-feed

Usage

Creates a instance of TwitterRSSFeed

const TwitterRSSFeed = require('twitter-rss-feed');

const trf = new TwitterRSSFeed({
  consumer_key: 'YOUR_CONSUMER_KEY',
  consumer_secret: 'YOUR_CONSUMER_SECRET',
  token: 'YOUR_ACCESS_TOKEN',
  token_secret: 'YOUR_ACCESS_SECRET'
});

Uses statuses_user_timeline method

// parameters for Twitter API (GET statuses/user_timeline)
const params = {
  'screen_name' : 'YOUR_SCREEN_NAME',
  'count' : '20',
  'tweet_mode' : 'extended'
};

// information of RSS feed
const info = {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/YOUR_SCREEN_NAME'
  }
};

// create RSS feed
const rss = await trf.statuses_user_timeline(params, info);
console.log(rss);

Uses favorites_list method

// parameters for Twitter API (GET favorites/list)
const params = {
  'screen_name' : 'YOUR_SCREEN_NAME',
  'count' : '20',
  'tweet_mode' : 'extended'
};

// information of RSS feed
const info = {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/YOUR_SCREEN_NAME/likes'
  }
};

// set this filter to opts.filters
// if you want to extract only the tweets of public user's tweets
const opts = {
  'filters': [TwitterRSSFeed.public_users_filter()]
};

// create RSS feed
const rss = await trf.favorites_list(params, info, opts);
console.log(rss);

Uses search_tweets method

// parameters for Twitter API (Standard search API)
const params = {
  'q' : 'SEARCH_QUERY',
  'count' : '20',
  'tweet_mode' : 'extended'
};

// information of RSS feed
const info = {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/search?q=SEARCH_QUERY'
  }
};

// create RSS feed
const rss = await trf.search_tweets(params, info);
console.log(rss);

Uses get and rss methods

// path of Twitter API (Ex. 'statuses/user_timeline')
const path = 'statuses/user_timeline';

// parameters for Twitter API (GET statuses/user_timeline)
const params = {
  'screen_name' : 'YOUR_SCREEN_NAME',
  'count' : '20',
  'tweet_mode' : 'extended'
};

// get tweet objects
const tweets = await trf.get(path, params);

// information of RSS feed
const info = {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/YOUR_SCREEN_NAME'
  }
};

// options
const opts = {};

// create RSS feed
const rss = trf.rss(tweets, info, opts);
console.log(rss);

Uses formatter

// parameters for Twitter API (GET statuses/user_timeline)
const params = {
  'screen_name' : 'YOUR_SCREEN_NAME',
  'count' : '20',
  'tweet_mode' : 'extended'
};

// information of RSS feed
const info = {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/YOUR_SCREEN_NAME'
  }
};

// create formatter function
const my_formatter = function(tweet) {
  const text = tweet.full_text ? tweet.full_text : tweet.text;
  return {
    title: '@' + tweet.user.screen_name + ': "' + text + '" / Twitter',
    description: text,
    link: 'https://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id_str,
    date: new Date(tweet.created_at)
  };
};

// set your formatter to opts.formatter
const opts = {
  'formatter': my_formatter
};

// create RSS feed
const rss = await trf.statuses_user_timeline(params, info, opts);
console.log(rss);

Uses promise object

const promise = trf.statuses_user_timeline({
  'screen_name' : 'YOUR_SCREEN_NAME',
  'count' : '20',
  'tweet_mode' : 'extended'
}, {
  'channel' : {
    'title' : 'Your RSS feed title',
    'description' : 'Your RSS feed title',
    'link' : 'https://twitter.com/YOUR_SCREEN_NAME'
  },
});

promise
.then(function(rss) {
  console.log(rss);
})
.catch(function(error) {
  console.log(error);
});

Examples

Documentation

Development

Install dependent packages

$ npm install

Run testing

$ npm test

Install local for testing

Specify a local repository directory.

$ npm install ../twitter-rss-feed-nodejs/

Generate an API documentation

$ npm run jsdoc

Release

$ rm package-lock.json
$ rm -r node_modules/
$ npm publish
$ git tag -a vX.X.X -m "YOUR TAGGING MESSAGE"
$ git push origin tags/vX.X.X

License

The package is available as open source under the terms of the MIT License.