Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
twitter2mongodb-cli
Advanced tools
Command line tool for extracting Twitter data to MongoDB databases
Richard Wen
rrwen.dev@gmail.com
Command line tool for extracting Twitter data to MongoDB databases
npm
npm install -g twitter2mongodb-cli
For the latest developer version, see Developer Install.
Get help:
twitter2mongodb --help
Open documentation in web browser:
twitter2mongodb doc twitter2mongodb
twitter2mongodb doc twitter
twitter2mongodb doc mongodb
See twitter2mongodb for programmatic usage.
An environment file .env
is used to store Twitter API credentials and MongoDB details.
Step 1. Set the default config for the .env
file:
twitter2mongodb
command will now use the designated .env
filetwitter2mongodb config set env path/to/.env
Step 2. Set Twitter API credentials
twitter2mongodb env set TWITTER_CONSUMER_KEY ***
twitter2mongodb env set TWITTER_CONSUMER_SECRET ***
twitter2mongodb env set TWITTER_ACCESS_TOKEN_KEY ***
twitter2mongodb env set TWITTER_ACCESS_TOKEN_SECRET ***
Step 3. Set MongoDB connection
twitter2mongodb env set MONGODB_CONNECTION mongodb://localhost:27017
The REST API obtains Twitter data in batches using search queries.
Step 1. Setup default twitter options:
get
, post
, delete
or stream
)twitter2mongodb config set twitter.method get
twitter2mongodb config set twitter.path search/tweets
twitter2mongodb config set twitter.params "{\"q\":\"twitter\"}"
Step 2. Setup default MongoDB options:
twitter2mongodb config set mongodb.database twitter2mongodb_database
twitter2mongodb config set mongodb.collection twitter_data
twitter2mongodb config set mongodb.method insertMany
twitter2mongodb config set jsonata statuses
Step 3. Extract Twitter data into MongoDB collection given setup options:
twitter2mongodb > log.csv
The Stream API obtains Twitter data in real-time using tracking filters.
Step 1. Setup default twitter options:
twitter2mongodb config set twitter.method stream
twitter2mongodb config set twitter.path statuses/filter
twitter2mongodb config set twitter.params "{\"track\":\"twitter\"}"
Step 2. Setup default MongoDB options:
twitter2mongodb config set mongodb.database twitter2mongodb_database
twitter2mongodb config set mongodb.collection twitter_data
twitter2mongodb config set mongodb.method insertOne
Step 3a. Stream Twitter data into MongoDB collection given setup options:
twitter2mongodb > log.csv
Step 3b. Stream Twitter data into a MongoDB collection as a service:
npm install pm2 -g
)pm2
to run the saved script as a servicetwitter2mongodb save path/to/script.js
pm2 start path/to/script.js
pm2 save
The logs are in the following Comma-Separated Values (CSV) format:
time_iso8601
: Time and date in ISO 8601 formatstatus
: Status of the logmessage
: Relevant messagesjson
: JSON object containing relevant debugging informationtime_iso8601 | status | message | json |
---|---|---|---|
... | ... | ... | ... |
See CONTRIBUTING.md for more details.
Install the latest developer version with npm
from github:
npm install git+https://github.com/rrwen/twitter2mongodb-cli
Install from git
cloned source:
npm
git clone https://github.com/rrwen/twitter2mongodb-cli
cd twitter2mongodb-cli
npm install
git clone https://github.com/rrwen/twitter2mongodb-cli
cd twitter2mongodb-cli
.env
file (see tests/README.md)npm install
npm test
twitter2mongodb-cli
folder, add all files and commit changesgit add .
git commit -a -m "Generic update"
git push
package.json
npm test
npm login
npm publish
The module twitter2mongodb-cli uses the following npm packages for its implementation:
npm | Purpose |
---|---|
path | Handle file and directory paths |
fs | Read and write config file |
envfile | Parse and write env files |
dotenv | Load environmental variables from a file |
yargs | Command line builder and parser |
yargs-command-config | Command for managing config files |
yargs-command-env | Command for managing env files |
twitter2mongodb | Extracts Twitter data to MongoDB |
opn | Open online browser documentation |
mongodb | Send queries to MongoDB database |
parse-mongo-url | Parse MongoDB urls |
path <-- Handle file and dir paths
|
fs <-- Read and write config file
|
envfile <-- parse and write env file
|
dotenv <-- load env file
|
yargs
|--- yargs-command-config <-- manage config
|--- yargs-command-env <-- manage env
|--- twitter2mongodb <-- default command
|--- opn <-- doc
|--- mongodb <-- query
|--- parse-mongo-url <-- parse MongoDB url for info
FAQs
Command line tool for extracting Twitter data to MongoDB databases
The npm package twitter2mongodb-cli receives a total of 2 weekly downloads. As such, twitter2mongodb-cli popularity was classified as not popular.
We found that twitter2mongodb-cli 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.