How to get all the tweets from a specific country?


Hello, I’m trying to get some data from twitter but I can’t seem to get a hold of the streaming API, I would like to get a stream from all the incoming tweets from my country and on the other hand I also wanna get all the previous tweets from my country also, can anyone give me a hand?


for streaming tweets, take a look at the statuses/filter command using the location parameter

for past tweets, take a look at the search/tweets command using the geocode parameter



Jonas is correct. (Thank you, Jonas!)

Currently, we do not offer a parameter in either the Streaming or REST APIs that would allow direct targeting of (and filtering by) country. However, as Jonas pointed out, you can request Tweets that have been geotagged (by the user who created them), with the geotag falling within certain parameters.

For the Streaming API (current Tweets, as they happen), check out the [node:5892, hash=“locations”, title=“documentation for the location parameter”] in the [node:10389] endpoint.

For the REST API (past Tweets), check out the documentation for the geocode parameter in the [node:10287] endpoint.

If you use boundaries that are geographically broader than just the country you’re interested in, you can then further filter those results within your own code by checking whether a particular Tweet’s geotag falls within the geographic boundaries of the country (which you will probably have to use a third-party database or library for).

Keep in mind, however, that using the options above will limit the Tweets returned to only those that have been geotagged, so you will miss many Tweets generated within the country of interest (since many users have not enabled geotagging).

I hope that’s helpful!


Actually, most of the users have their profile location filled (which is not really geotagged but typed by the users instead). I needed to get all the possible tweets from my country containing some words, but since track and location attributes have not AND but OR behavior I started filtering the results myself based on the profile location of the user who has wrote the tweet.

That could be inaccurate in a large number of cases but there are not a lot of other possibilities.

I will find myself very very happy if someday twitter allow us to get some other data from tweets (like the country or city -at least- of the tweet based on some ISP data). You can have the IP of the users and you will have the country/city which may be exposed as text so you can still care about user’s privacy by not showing their actual IP Address.


Thanks for the clearifications…this is well appreciated.