This is a complete list of search operators that you can use with Twitter Bots. The bots will use the Twitter API to find tweets that match your search criteria and perform the action on each of the matching tweets.

Twitter Search Operators

Search QueryDescription
red applesTweets that contain both “red” and “apples” anywhere. This is the default operator
“merry chrismtas”Tweets that contain the exact phrase in the same order
Apples OR OrangesUse the Boolean OR operator in capital letters
#foodAll tweets that contain a particular hashtag
@labnolTweets that @mention or reference a particular user
grapes -apples -orangesTweets that contain grapes but not the words apple or oranges
from:BarackObamaTweets written by a specific Twitter user
from:BarackObama to:WhitehouseTwitter from one user that mention another specific user
to:BarackObama -filter:links -filter:imagesTweets that do not contain links or images
elections list:TIME/time-staffSearch for tweets from users who belong to a particular Twitter list
#foodrecipe lang:enTweets sent in particular language (en = English). Do not use the lang operator to search tweets in any language.
#holiday good OR amazing OR awesome filter:imagesTweets that mention #holiday, described as awesome or amazing, and include photographs
tornado filter:mediaShow tornado tweets containing images or videos
music concert filter:native_videoShow tweets that contain native video (uploaded inside tweet)
india filter:newsShows tweets containing news stores
iphone url:amazonShow tweets that contain the word “iphone” a URL with the word amazon anywhere in the web address.
awesome video filter:linksShow tweets that contain the words “awesome” and “video” and include a link (URL)
include:repliesThe Twitter bot, by default, will ignore tweets that are replies to another tweets
include:retweetsThe Twitter bot, by default, will skip tweets that are retweets. We suggest that you do not include this filter.

How to Search Tweets by location

You can use Twitter bots to only search for geotagged tweets but it takes a few extra steps to construct your search query using geolocation.

Go to Google Maps Lookup and search for a location (let’s say Battery Park, NY).

google-maps.png

The info window will display the latitude and longitude information of that place. In the Twitter bot search box, enter geocode:latitude,longitude,radius, where radius units must be specified as either mi (miles) or km (kilometers).

For this example, our geolocation query would be:

geocode:40.7024946,-74.016858,2mi (Search tweets by users located within 2 mile radius of the Battery Park area)

How to Search Tweets by popularity

Thousands of tweets are posted every minute and a good number of them could be spam. Twitter offers no option to filter tweets by quality but, while setting up Twitter Bots, you can set up a threshold and any tweet not matching that number will be ignored.

You can specify the Follower / Friend count and tweets from users who have less number of followers / friend that the specified number are ignored.

Similarly, you can specify a minimum number of favorites / retweet count and the bot would only look at tweets that have been retweeted or favorited at least that many number of times.

twitter-popular-count.png

Twitter Search Limitations

While the Twitter search API is powerful, there are few limitations that you should be aware of.

  1. Limit your searches to 10 keywords and operators.
  2. The near: search operator does not work with Twitter bots. Use the geocode: operator as described above.
  3. You cannot use before or after search operators to search old tweets by date. These date search operators only work on the Twitter website.
  4. Twitter search results have a 7 day limit and no tweets will be found for a date older than one week.
  5. Twitter API may not handle queries that are either too long or contain too many search operators.
  6. The Twitter Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
  7. You can use the lang operator to restrict tweets to the given language but language detection may not be perfect.
  8. When conducting geo searches, the search API will first attempt to find Tweets which have lat/long within the queried geocode, and in case of not having success, it will attempt to find Tweets created by users whose profile location can be reverse geocoded into a lat/long within the queried geocode, meaning that is possible to receive Tweets which do not include lat/long information.