1
votes

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.

2

2 Answers

3
votes

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.

0
votes

There are a lot of Twitter modules in Node - it will be much easier to use one of them:

See this answer for more options and more details:

Why isnt that documented on the page anywere?

I recommend using one of the Node modules for Twitter API. Many of them have great documentation.

Is %3A = @? How do I actually make that search?

No. "@" is %40. %3a is ":" (a colon). If you use a Node module to talk to the Twitter API then you will not have to worry about details like that.