views:

14

answers:

1

Can I fetch all the tweets from users of a particular location filtered by a particular keyword? For example, I want to look up all the tweets made during a day in a particular location with a keyword "XYZ". Can this be done?

A: 

Yep, you can use the form on http://search.twitter.com/advanced to construct an advanced query.
Also check out http://dev.twitter.com/doc/get/search for more API info.

So, for example, finding tweets containing "very nice" from users located within 100 miles from Los Angeles would be written as:

near:"Los Angeles" within:100mi "very nice"

Your search URL would then look like:
http://search.twitter.com/search?q=near%3A%22Los+Angeles%22+within%3A100mi+%22very+nice%22

You can also get these results in JSON or ATOM format but you'll need to include the geocode parameter that the search page generates. Easiest way to find this is to copy the param from the "Feed for this query" link on the top-right of the page.

So, results in JSON format:
http://search.twitter.com/search.json?geocode=34.052187%2C-118.243425%2C25.0km&q=near%3A%22Los+Angeles%22+within%3A100mi+%22very+nice%22

Results in ATOM format:
http://search.twitter.com/search.atom?geocode=34.052187%2C-118.243425%2C25.0km&q=near%3A%22Los+Angeles%22+within%3A100mi+%22very+nice%22

Specifying a date range is also possible; use the advanced search form to help you construct what you need.

Chris

related questions