Joy
Joy

Reputation: 542

Is there a way to filter out Retweets from results of search_tweets using Tweepy?

I'm using Tweepy to query Tweets with certain keywords and am able to a get a list of Tweet objects (or Status objects?) (https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/tweet).

I'm wondering if there's a way to remove Retweets from all the Tweets since I want to look at original Tweets and replies specifically. If there's an attribute in the Tweet object, that'd solve my problem but didn't figure that out so far.

Thanks in advance!

Upvotes: 0

Views: 1046

Answers (1)

Harmon758
Harmon758

Reputation: 5157

If you're using the standard search API with API.search_tweets, you can use the -filter:retweets operator in your query.

Also, if you're using API.search_tweets, you're using Twitter API v1.1, and https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/tweet is the corresponding documentation for the Tweet object. You can distinguish Retweets by the existence of a retweeted_status attribute.

Upvotes: 2

Related Questions