Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Exclude retweets and replies in a search api?

How to Exclude retweets and replies in a search api?

I am trying to fetch the feeds from twitter using search api, in the result I am getting replies and retweets also.

So I want to exclude replies and retweets.

How to do it anybody help me.

This is my url:

https://api.twitter.com/1.1/search/tweets.json?q=from:rioferdy5&count=20&result_type=recent

like image 560
rakesh r Avatar asked Jan 14 '15 11:01

rakesh r


People also ask

How do you filter a retweet in Python?

If you fetch tweets using the tweepy library of python then you can achieve filtering retweets by appending “ -filter:retweets” to the search query. The code will look something like this: for status in tweepy. Cursor(api.search,q=query+" -filter:retweets",lang='en',result_type='recent').

Can you filter Retweets?

There is no way to filter from the web UI all retweets. What you will need to do is go to each profile you follow, then: Click the gear icon. Select Turn off Retweets.

What means retweet in twitter?

What is a Retweet? A Tweet that you share publicly with your followers is known as a Retweet. This is a great way to pass along news and interesting discoveries on Twitter. You have the option to add your own comments and/or media before Retweeting.


2 Answers

I beleive the above is incorrect, you can use filters in the search API but the documentation is very poor (non-existent?).

Your query would become:

?q=from:rioferdy AND -filter:retweets AND -filter:replies&count=20&result_type=recent

More tips for filtering were obtained here: How to Master Twitter Search: Basic Boolean Operators and Filters

like image 141
Paul Thomas Avatar answered Oct 12 '22 09:10

Paul Thomas


Old post, but people might still stumble upon it.

Most query operators are documented here: https://dev.twitter.com/rest/public/search

But for the search/tweets method, you can also specify exclude:replies and/or exclude:retweets to filter out replies and retweets from the result.

Just test it in the API Console Tool and see for yourself.

Bonus: Another undocumented query operator is filter:verified to get tweets from verified users.

Example query: cats filter:vine filter:verified exclude:replies exclude:retweets

like image 20
phuc77 Avatar answered Oct 12 '22 09:10

phuc77