Search code examples
tweepytwitter-streaming-api

Is it possible to perform a NOT search using the Twitter streaming API through Tweepy?


twitterStream.filter(track=["aids","hiv","hiv aids"])

track=["aids","hiv"] gives me, aids OR hiv

track=["aids hiv"] gives, aids AND hiv.

But, what do we do for NOT ?


Solution

  • Twitter's API filter and track has not a specific case for the NOT operator, probably a not query will tend to return too many results and being computationally heavy. Tweepy mimics the Twitter API filter and track, so you have no way to do a NOT in the query.

    The track/filter are documented here: https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters

    What you can do is delete the streams you don't need after you get them based on the tag.