Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dstwitter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dstwitter

Simplify usage of twitter API

  • 0.1.2
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

dstwitter - Easy use of twitter API

dstwitter is a module for simplifying data analysis and manipulation of twitter tweets and users. It integrates into dstools by adding functions to the dstools collection object. See the dstools documentation for some more information about the dstools module.

You will need access token key, access token secret, consumer key and consumer token to run the code.

Examples

Initialize the environment

const ME = 'MY_SCREEN_NAME';
require('dstwitter');//initialize twitter functions
start = require('dstools').Collection
.context('twitter',{ //context function sets the context twitter credentials
	access_token_key:'FILL-IN',
	access_token_secret : 'FILL-IN',
	consumer_key: 'FILL-IN',
	consumer_secret: 'FILL-IN'
});

Show some stats

//get followers and following IDs
let followers = start.followersIDs(ME);
let following = start.followingIDs(ME);

//some stats
console.log('followers:',followers.count());
console.log('I follow:',following.count());
console.log("Follow me that I don't follow back:", followers.drop(following).count());
console.log("Don't follow me back:", following.drop(followers).count());

Follow back all users that follow me

//follow users that follow me (that I don't already follow)
followers
	.drop(following) //ignore users I am already following
	.follow(); //follow them

### create a word cloud of user tweets
start.tweets('SOME_SCREEN_NAME',10000)
.column('text').toLowerCase()
.terms().dropStopwords('term')
.sortDesc('count').head(50).wordCloud('term','count').save('word-cloud.html');

Find users tweeting about javascript and react

start.searchTweets('javascript react',10000,{result_type:'mixed'})
.filter((tweet)=>!tweet.text.startsWith('RT @'))//filter out retweets
.map((tweet)=>tweet.user)//get users of the tweets
.column('screen_name')//get their screen name
.do((names)=>console.log('screen names',names.join()));//print names after finish loading tweets

Installing dstwitter

Install dstwitter using npm

npm install dstwitter

Documentation

Documentation of the package is over here

License

MIT

Keywords

FAQs

Package last updated on 08 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc