This video uses a metaphor of “Twitterville” to illustrate the opportunities to use the Twitter Search feature to find people and information, read news and discover emerging information. It teaches how Twitter Search: Helps businesses listen to customer feedback Creates a real-time news source.
Standard
The best way to build a standard query and test if it’s valid and will return matched Tweets is to first try it at twitter.com/search. As you get a satisfactory result set, the URL loaded in the browser will contain the proper query syntax that can be reused in the standard search API endpoint. Here’s an example:
Please note that the API requires that the request be authenticated (check Authentication & Authorization documentation for more details on this). Note that the standard search API only serves data from the last week. If you need historical data odler than seven days, check out the premium and enterprise search APIs.
The query can have operators that modify its behavior. the available operators are:
Operator | Finds Tweets... |
---|---|
watching now | containing both “watching” and “now”. This is the default operator. |
“happy hour” | containing the exact phrase “happy hour”. |
love OR hate | containing either “love” or “hate” (or both). |
beer -root | containing “beer” but not “root”. |
#haiku | containing the hashtag “haiku”. |
from:interior | sent from Twitter account “interior”. |
list:NASA/astronauts-in-space-now | sent from a Twitter account in the NASA list astronauts-in-space-now |
to:NASA | a Tweet authored in reply to Twitter account “NASA”. |
@NASA | mentioning Twitter account “NASA”. |
politics filter:safe | containing “politics” with Tweets marked as potentially sensitive removed. |
puppy filter:media | containing “puppy” and an image or video. |
puppy -filter:retweets | containing “puppy”, filtering out retweets |
puppy filter:native_video | containing “puppy” and an uploaded video, Amplify video, Periscope, or Vine. |
puppy filter:periscope | containing “puppy” and a Periscope video URL. |
puppy filter:vine | containing “puppy” and a Vine. |
puppy filter:images | containing “puppy” and links identified as photos, including third parties such as Instagram. |
puppy filter:twimg | containing “puppy” and a pic.twitter.com link representing one or more photos. |
hilarious filter:links | containing “hilarious” and linking to URL. |
puppy url:amazon | containing “puppy” and a URL with the word “amazon” anywhere within it. |
superhero since:2015-12-21 | containing “superhero” and sent since date “2015-12-21” (year-month-day). |
puppy until:2015-12-21 | containing “puppy” and sent before the date “2015-12-21”. |
movie -scary :) | containing “movie”, but not “scary”, and with a positive attitude. |
flight :( | containing “flight” and with a negative attitude. |
traffic ? | containing “traffic” and asking a question. |
Please, make sure to URL encode these queries before making the request. There are several online tools to help you to do that, or you can search at twitter.com/search and copy the encoded URL from the browser’s address bar. The table below shows some example mappings from search queries to URL encoded queries:
Search query | URL encoded query |
---|---|
#haiku #poetry | %23haiku+%23poetry |
“happy hour” :) | %22happy%20hour%22%20%3A%29 |
Note that the space character can be represented by “%20” or “+” sign.
There is a set of additional parameters that allows a better control of the search results. The GET search/tweets documentation has detailed information about the usage of the parameters, this section will only give a brief description of their capabilities:
Click “Customize” to review options, including controls to reject the use of cookies for personalization and information about browser-level controls to reject some or all cookies for other uses. You can also visit g.co/privacytools anytime.