Search code examples
node.jstwitter

Twitter api search tweets tweeted by user


I'm trying to search tweets tweeted by a specific user, but I can't decipher the documentation.

I read through this page https://dev.twitter.com/rest/public/search, and this page https://dev.twitter.com/rest/reference/get/search/tweets and I can see that there is no parameter user or something similar.

But at the bottom of the first page is:

When you want the most popular tweets of a specific user using a hashtag:

You want: popular Tweets from @Cmdr_Hadfield mentioning the hashtag #nasa
Your search URL is: https://api.twitter.com/1.1/search/tweets.json?q=from%3ACmdr_Hadfield%20%23nasa&result_type=popular

Why isnt that documented on the page anywere? Is %3A = @? How do I actually make that search?

Edit:

I'm using https://www.npmjs.com/package/twitter - 1.7.0.


Solution

  • For anyone trying to do the same thing, you just have to decode the characters from the example query

    https://api.twitter.com/1.1/search/tweets.json?q=from%3ACmdr_Hadfield%20%23nasa&result_type=popular
    

    %3A would be :

    %20 would be

    and after that you just write your query:

    twitterClient.get('https://api.twitter.com/1.1/search/tweets.json', {q: 'from:name param',count: "100"},  function(error, tweets, response){
        if(error) throw error;
        console.log(tweets);  
    }); 
    

    This should be working. It s working for me.