find tweet location - twitter

I'm using the Twitter search api to search for a keyword so I can grab all the tweets containing that keyword. I also need to find the location of these tweets. Is this possible? I've looked through the JSON and the 'Geo' property is always null - i'd be happy to just use the location that the user has filled out in their profile but I can't see that this is available through the search api.
I've seen lots of apps that allow you to find tweets nearby based on your location but I want to do something different. find tweets by keyword and then find their location.
Is this possible?

Apologies, just found a solution.
The REST api allows me to query based on a search string:
http://search.twitter.com/search.json?&q=twitter
and this returns some json including the user id and then from there I can query again using this:
http://api.twitter.com/1/users/show.xml?user_id=1401881
which returns me user info including a location.

Related

Youtube API v3 Return Lat/Lng

I can search lat/long with YouTube v3 successfully,
https://www.googleapis.com/youtube/v3/search?part=snippet,id&maxResults=50&type=video& videoType=any&key=foobar&location=40.7127,74.0059&locationRadius=100km
However, the response doesnt give me the individual videos lat/lng in the results.
The API doc says:
The part parameter specifies a comma-separated list of one or more
search resource properties that the API response will include. Set the
parameter value to snippet.
I cannot find any other search resource properties besides id and snippet in Search:list.
(Why would the API include that first sentence if there are only 2 options?) I digress.
Question-
Is there any way that I can retrieve YT videos lat/long based on lat/long search?
You can have lat/long parameters of the videos you own or manage. But due to privacy reasons (been able to locate people from their uploads.) you won't be able to get specific geolocations of other people's uploads.

How do I search tweets of a given multiple users based on certain criteria using twitter api?

I have list of users
['foo','bar']
I want to search whether they have checked in somewhere or not (using 4sq api)..
So basically, all I am looking for is that whether their tweets contain "\4sq.com\" or not?
I get very confused looking into their api?
Bonus points if the steps can be implemented in python.
Thanks
You have two options for checking a user's tweets:
One option is to look through the tweets in their User Timeline (accessible in Tweepy through api.user_timeline). However, you may have to search through a lot of unrelated Tweets before you come across the one your looking for. Given how many tweets some users have, you might want to only look thorough tweets more recent than a certain date (you can look at the created_at attribute of returned tweets).
The other option is to use the Search API (accessible in Tweepy though 'api.search'). This has the advantage of allowing you specify a search query, giving you relevant tweets. However, you will need to search through the tweets until you find one by the user you're looking for. Again, you might want to limit the date range of tweets that you search through.

Twitter API location of tweets

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?
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.

Twitter API - search tweets and filter by bio keywords

Is there any way at all to search for latest tweets by keyword, then - crucially - only show the tweets when the twitter user it belongs to has a keyword in their bio? I've been searching for ways to do this and have found nothing other than sites (e.g FollowerWonk) which offer this functionality but not an API to tap into. Any advice appreciated!
You can use the regular Twitter api to search for Tweets containing your keyword. All docs are at dev.twitter.com. In the results set that you get back, you can also get the bio of each user. You could make a subselection in that text. We found the easiest way to load the results into a SOLR instance, and search on anything you want.

How to get location of Tweets with Twitter search API

The statuses/user_timeline part of the Twitter API returns geolocation data as "place" along with each Tweet. The search API, on the other hand, does not return this location data (as far as I can tell). Is there a way to get location data with the search API?
There is a geo field in each result of the search resource (see the example in the documentation), which is a form of geolocation, but is not the exact same thing as the place field in the statuses/user_timeline.
Alternatively you can make another request using the id of the result through the statuses/show/:id resource (see documentation) which returns both the geo and place fields, but that would mean making one more request per result.
Matt asked this question directly to Twitter and got a response, and the dev who answered pointed out that the JSON format does include a 'geo' attribute.

Resources