How can I use Twitter Search API
(or other) to get a list of tweets which have the "geo"
param?
--EDIT--
By example: I wont get list of geotagged tweets, by #apple tag. Without location filter, worldwide.
How can I use Twitter Search API
(or other) to get a list of tweets which have the "geo"
param?
--EDIT--
By example: I wont get list of geotagged tweets, by #apple tag. Without location filter, worldwide.
Looks like the latest API supports that; simply use a large enough geo region for your query:
-180,-90,180,90
See more from the API link for filter and location
The streaming API allowed you to filter by a location and the search API allows you to search by geocode. You can find more information on these services on our developer resources site.
Streaming API: http://dev.twitter.com/pages/streaming_api
Example: Create a file called ‘locations’ that contains, excluding the quotation marks, the phrase: “locations=-122.75,36.8,-121.75,37.8,-74,40,-73,41” then execute:
curl -d @locations http://stream.twitter.com/1/statuses/filter.json -uAnyTwitterUser:Password.
You will receive all geo tagged tweets from the San Francisco and New York City area.
Search API: http://dev.twitter.com/doc/get/search
Example:
http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
geocode=37.781157,-122.398720,1mi
, as shown in your example, that is also a "filtered feed", insofar as requesting only geotagged tweets is a "filtered feed." It's fine that there's no way to do this currently, and thank you for stating that, but providing that feature would waste no more server time than existing geotag filters and it would consume LESS bandwidth because we wouldn't have to pull down ALL tweets when we only want a subset.
From the Twitter API
Documentation, this should be the format of your search query:
http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
Where 37.781157
is the latitude, -122.398720
is the longitude and 1mi
is the radius to search within.
# geocode Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
Dec 2, 2010 at 16:45
You can look for every tweet but save only the geotaged ones. I know it dont make a lot of sense, but works quite well.
if you call you search results, you can state
for result in results:
if result.geo != None:
print result.text.encode('utf-8', errors='ignore') # or do anything you want with the tweets
Use -180,-90,180,90
to get any geotagged tweet.