skip to Main Content

I am trying to search for the tweets from multiple users which contains the specific keyword.
Is there any specific twitter API to do so? and If there is, can you tell me how to get the search result?
I need to pass at least 10 users at a time and 1 keyword.

2

Answers


  1. If you’re working with Node.js, then there is a helpful npm package ‘twit’.

    For searching the tweets with the specific keyword:

        // I only want to see tweets about my favorite fruits. Same result as doing { track: 'bananas,oranges,strawberries' }
        
    var stream = T.stream('statuses/filter', { track: ['bananas', 'oranges', 'strawberries'] })
    
    Login or Signup to reply.
  2. var Twit = require('twit');
    var util = require('util');
    
    var config =require('./config');
    
    var T = new Twit(config)
    var stream = T.stream('statuses/filter', { follow: ['56488059','2227355222'] , track: ['Covid','Corona'] , language: ['en'] });
    
    
    
    
    stream.on('tweet', (tweet) => {
        console.log(tweet)
        console.log('---------------------')
        }
     );
    

    follow contains the user_ids , and track contains the keywords.

    module.exports = {
        
        consumer_key : "",
        consumer_secret : "",
        access_token : "",
        access_token_secret : ""
        
       }
    

    config.js contains the credentials from twitter developer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search