A NodeJS based client to extract tweets from twitter API using twit package and express web application framework.
- The client can be used to search for a particular term with added filter of tweets with a particular number of retweets.
- Search term can be specified in the key twitter_api_search_term of config.json. Example: "#custserv"
- Value to filter tweets based on number of retweets can be specified in the key min_retweet_count_value of config.json.
Make sure these software dependencies are setup on your system:
Name | Version |
---|---|
NodeJS | v4.4.2 or greater |
npm | v3.8.6 or greater |
Make sure Github local credentials are setup in your system. You can refer to Setup Git tutorial for help.
git clone git@github.com:rkgudboy/node-twitter-client.git
Enter into the directory of cloned project
cd node-twitter-client
These are the dependencies for running this project, which have been defined in package.json:
package | Description | Version |
---|---|---|
express | NodeJS Web Application Framework | v4.14.0 |
twit | Twitter API Client for NodeJS | v2.0.0-beta7 |
pug | Template Engine for NodeJS | v2.2.5 |
After navigating to node-twitter-client directory, above mentioned node dependencies, can be installed by running the command:
npm install
Create config.json file from config_template.json file. This file specifies the parameters such as Twitter API keys and port on which our app will run. Token and Secret of twitter App for communication with twitter API needs to be entered here in keys twitter_api_consumer_key, twitter_api_consumer_secret, twitter_api_access_token, twitter_api_access_token_secret. These can be generated at https://apps.twitter.com/
For evaluation purpose default values have been provided within config_template.json in the node-twitter-client directory.
cp config_template.json config.json
Run npm scripts to start the build process. Depending on your type of environment, choose any one:
-
Development environment
Starts build process using a watcher. Build process will start again, as soon as any browser related file is changed. Useful while doing development.
npm run build:watch
-
Production environment
Runs build process once to prepare files for displaying in browser. Use this when running the app on production and for browsing purpose.
npm run build
Start the server after build has completed. Depending on type of environment you are executing the step, choose any one:
-
Development environment
Starts server using a watcher, so that server is restarted by watcher as soon as any JS file is changed without having to manually enter the command. Useful during development stage.
node run server:watch
-
Production environment
Starts the server in production mode for viewing over port defined in config.json.
NODE_ENV=production npm run server
Result can be seen by opening following link in your web browser : http://localhost:{port}
example - http://localhost:7777