Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
twitter2mongodb
Advanced tools
Richard Wen
rrwen.dev@gmail.com
Module for extracting Twitter data to MongoDB databases
npm
npm install --save twitter2mongodb
npm install --save dotenv
For the latest developer version, see Developer Install.
It is recommended to use a .env
file at the root of your project directory with the following contents:
TWITTER_CONSUMER_KEY
: Consumer key (API Key)TWITTER_CONSUMER_SECRET
: Consumer secret (API secret) TWITTER_ACCESS_TOKEN_KEY
: Access tokenTWITTER_ACCESS_TOKEN_SECRET
: Access token secretMONGODB_CONNECTION
: MongoDB connection stringMONGODB_DATABASE
: MongoDB database nameMONGODB_COLLECTION
: MongoDB collection nameTWITTER_CONSUMER_KEY=***
TWITTER_CONSUMER_SECRET=***
TWITTER_ACCESS_TOKEN_KEY=***
TWITTER_ACCESS_TOKEN_SECRET=***
MONGODB_CONNECTION=mongodb://localhost:27017
MONGODB_DATABASE=test
MONGODB_COLLECTION=twitter_data
The .env
file above can be loaded using dotenv:
require('dotenv').config();
See Documentation for more details.
.env
file variablestwitter2mongodb
options
objecttwitter
from GET search/tweets
jsonata
filter for statuses key onlytwitter2mongodb
with the REST API optionsrequire('dotenv').config();
var twitter2mongodb = require('twitter2mongodb');
// (options) Initialize options object
var options = {
twitter: {},
mongodb: {}
};
// (options_twitter_rest) Search for keyword 'twitter' in path 'GET search/tweets'
options.twitter.method = 'get'; // get, post, or stream
options.twitter.path = 'search/tweets'; // api path
options.twitter.params = {q: 'twitter'}; // query tweets
// (options_jsonata) Filter for statuses array using jsonata
options.jsonata = 'statuses';
// (options_mongodb) MongoDB options
options.mongodb.method = 'insertMany'; // insert many objects due to array
// (twitter2mongodb_rest) Query tweets using REST API into MongoDB collection
twitter2mongodb(options)
.then(data => {
console.log(data);
}).catch(err => {
console.error(err.message);
});
.env
file variablestwitter2mongodb
options
objecttwitter
from POST statuses/filter
tweets
when they are receivedtwitter2return
with the Stream API optionsrequire('dotenv').config();
var twitter2mongodb = require('twitter2mongodb');
// (options) Initialize options object
var options = {
twitter: {},
mongodb: {}
};
// (options_twitter_connection) Track keyword 'twitter' in path 'POST statuses/filter'
options.twitter.method = 'stream'; // get, post, or stream
options.twitter.path = 'statuses/filter'; // api path
options.twitter.params = {track: 'twitter'}; // query tweets
// (options_mongodb) MongoDB options
options.mongodb.method = 'insertOne';
options.mongodb.check = function(tweets) {return(true)}; // only insert if returns true
// (twitter2mongodb_stream) Stream tweets into MongoDB collection
var stream = twitter2mongodb(options);
stream.on('error', function(error) {
console.error(error.message);
});
See CONTRIBUTING.md for more details.
Install the latest developer version with npm
from github:
npm install git+https://github.com/rrwen/twitter2mongodb
Install from git
cloned source:
npm
git clone https://github.com/rrwen/twitter2mongodb
cd twitter2mongodb
npm install
git clone https://github.com/rrwen/twitter2mongodb
cd twitter2mongodb
.env
file (see tests/README.md)npm install
npm test
Use documentationjs to generate html documentation in the docs
folder:
npm run docs
See JSDoc style for formatting syntax.
twitter2mongodb
folder, add all files and commit changesgit add .
git commit -a -m "Generic update"
git push
package.json
npm test
npm run docs
npm login
npm publish
The module twitter2mongodb uses the following npm packages for its implementation:
npm | Purpose |
---|---|
twitter2return | Connections to the Twitter API REST and Streaming Application Programming Interfaces (APIs) using twitter, and Filters with jsonata before inserting into MongoDB |
mongodb | Insert Twitter data to MongoDB collections |
twitter2return <-- Extract Twitter data from API and Filter JSON data
|
mongodb <-- Insert filtered Twitter data into MongoDB collection
FAQs
Module for extracting Twitter data to MongoDB databases
The npm package twitter2mongodb receives a total of 1 weekly downloads. As such, twitter2mongodb popularity was classified as not popular.
We found that twitter2mongodb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.