TwitterRSSFeed: Twitter RSS feed Node.js library
- Homepage: GitHub - niwasawa/twitter-rss-feed-nodejs: TwitterRSSFeed: Twitter RSS feed Node.js library
- twitter-rss-feed - npm
- This library is under development and unstable.
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 feedconst info = { 'channel' : { 'title' : 'Your RSS feed title', 'description' : 'Your RSS feed title', 'link' : 'https://twitter.com/YOUR_SCREEN_NAME' }}; // create RSS feedconst 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 feedconst 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 tweetsconst opts = { 'filters': [TwitterRSSFeed.public_users_filter()]}; // create RSS feedconst 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 feedconst info = { 'channel' : { 'title' : 'Your RSS feed title', 'description' : 'Your RSS feed title', 'link' : 'https://twitter.com/search?q=SEARCH_QUERY' }}; // create RSS feedconst 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 objectsconst tweets = await trf.get(path, params); // information of RSS feedconst info = { 'channel' : { 'title' : 'Your RSS feed title', 'description' : 'Your RSS feed title', 'link' : 'https://twitter.com/YOUR_SCREEN_NAME' }}; // optionsconst opts = {}; // create RSS feedconst 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 feedconst info = { 'channel' : { 'title' : 'Your RSS feed title', 'description' : 'Your RSS feed title', 'link' : 'https://twitter.com/YOUR_SCREEN_NAME' }}; // create formatter functionconst 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.formatterconst opts = { 'formatter': my_formatter}; // create RSS feedconst 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
- TwitterRSSFeed API Reference
- GET statuses/user_timeline — Twitter Developers
- GET favorites/list — Twitter Developers
- Standard search API — Twitter Developers
- Tweet updates — Twitter Developers
- more than 140 characters, tweet_mode=extended, full_text
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.