The Search API for twitter works by returning what you ask for. To use the search API use the URL in your program, or web browser (I recommend seeing it with the Firefox json viewer): There are actually 5 ways to use the Search API.
- search
- trends
- trends/current
- trends/daily
- trends/weekly
Here is an example of how to use the search API. To see how all the others work see Twitter API documentation.
- http://search.twitter.com/search.format
- The formats are:
- JSON
- Atom
- For example: http://search.twitter.com/search.json
- For example: http://search.twitter.com/search.atom
There are a lot of parameters that let you see what type things you want to search for. I can give an example below for me searching for what Apigee tweets about. I will use the q parameter in this example, and use it search from a user. The example will be in both formats as follows:
- http://search.twitter.com/search.atom?q=from:apigee
- http://search.twitter.com/search.json?q=from:apigee
You can place both URL's in your Firefox web browser with the json viewer, and they should both let you see my tweets only. You can also view them using cURL (cURL is a very versatile command line utility which is designed to script web pages interactions.)
As you can see the Twitter search API is really very simple to use, and can easily be implemented into the app that you are building. Take this very simple python code that uses the twitter API. First you must download the twitter library for python. Here is the code:
import twitter //This is how you call the twitter library.
client = twitter.Api () //You can expose the twitter API with this class
latest_post = client.GetUserTimeline("apigee")// This makes sure the the twitter.API class will fetch Apigee recently posted public tweets.
print [s.text for s in latest_post]//This will print out only the text for Apigee posts.