I’m thinking up a new website idea which would allow a visitor to view on a map where certain things have happened. I want to use Twitter, with the idea that someone tweets using a specific hashtag. I want to capture that tweet using the API and find the location of where the tweet came from. Is this possible?
Share
It is possible. However there are lots of tweets (a majority in reality) which do not get any location and it is impossible to get it for these ones. To be located, a user must enable location in its account parameters and give its location with the tweet while posting it but a majority of tweeps do not do that.
For retrieving tweets location, you just have to download the tweet with the corresponding Twitter API endpoint (
GET statuses/show/:id). Once you get the tweet, search its"coordinates"field. This field has got a subfield also called"coordinates". This subfield is a list with two numbers :[longitude, latitude]. For further information, refer to the Twitter Developers documentation about tweets and coordinates.