The Twitter-search features the possibility to search for a source of tweet by using the parameter "source:" (e.g. source:tweetdeck).
If I just search for that it complains about a missing query, but I actually want to search for any tweets from a certain source.
Is that possible?
You need to have some form of criteria, even if it's just 'recent tweets'. To query every single tweet is, I suspect, not possible at all and certainly not within the capabilities of the API.
Note: My mistake - was thinking of one of the REST APIs.
Related
How can I retrieve all Arabic speaking channels locally in Israel.
Using the API explorer, I don't see such an option.
Which fields are mandatory for search to call the search API?
Is there any way to fulfill this task?
Update:
API Explorer
I couldn't get results
There are lots of parameters in the API v3 Docs for Search that you can play around with, some in particular you might find helpful are:
location
locationRadius
regionCode
relevanceLanguage
and you'll need to set type = "channel" to return only channels.
The only mandatory parameter is part which is what data you want returned from your results. For this search call, you only have one option for part, which is "snippet".
This is the only way to do it simply within your multiple parameters, and it will take 100 quota per search, assuming you have an API key already.
If you press 'Try This API' on the right, it'll even give you code snippets you can copy in a variety of languages, since you didn't specify one in the prompt.
Depending on the language, a call could look like the following:
GET https://youtube.googleapis.com/youtube/v3/search?part=snippet&location=Israel®ionCode=IL&relevanceLanguage=ar&type=channel&key=[YOUR_API_KEY] HTTP/1.1
In my app I used the get_respondent_list API in API v2 to get an overview of the responses and to allow me to select those responses which were relevant to download in greater detail - fields of interest to me included date_modified, status .
I had hoped that /surveys/{ID}/responses would give a similar facility but all it returns for each response is href and id. The parameters of the call enable me to filter the list in various ways but I would need to make several calls to identify the different categories that I am interested in.
When I made a similar point about the survey list it turned out there was an incorrectly documented include parameter which I could use to get additional fields in the response. I tried that for /surveys/{id}/responses but that was rejected. Could such a facility be added?
If not I guess I will go for /surveys/{id}/responses/bulk and do all the work in the app.
The bulk endpoint is the correct choice. It is basically a call to /surveys/{ID}/responses with 'include' covering every field. The only downside is is the smaller maximum page size. Not sure sure what additional work you are referring to, since you would need to handle pagination at /surveys/{ID}/responses for more than 1000 responses, and all the fields you are looking for are available at the top level of the returned response dictionary.
This wrapper for the API (not written by me) makes it fairly easy to get all the responses from a survey paired with the relevant question details.
In order to get the data structured in a way that resembles the output from the manual export, a bit of gymnastics is needed (I can recommend Pandas' .pivot_table(). Which columns that contain the actual answers vary depending on questions type, adding further complications depending on the complexity of the survey.
I want to get a list of users who have used a particular hashtag. Eg. #ManOfSteel.
How can I get a list of the users who are using that hashtag as well as their details (like which city they are tweeting from) using a twitter API or any other means?
Yes, you can. And it's quite simple, really.
According to the documentation:
GET search/tweets: - Returns a collection of relevant Tweets matching a specified query.
Resource URL: https://api.twitter.com/1.1/search/tweets.json
Now if you scroll down on that page, it gives an example of what a query for a tweet returns (I took a screen, sorry about the appalling arrow, it's 10am here and I haven't had my tea yet).
Great! So you know the URL and method (GET) that you need to get your data. As for searching for a hashtag specifically, the query documentation is what you're after.
This is basically as urlencoded string in the GET request like: ?q=#hashtag. Perform the search like that and you'll get back the data above. Then just loop through it, find the user object, and grab the value location key if you want the user's city.
Now, as for a library to interact with the twitter API, you haven't even stated what language you're using. From your profile, you use JAVA I'm guessing. Regardless, checkout the libraries page on the twitter dev site - there's one for JAVA that looks pretty good (and many for other languages too).
If you were using php, this post would be immensely helpful.
Is there an API call which will return all the tweets which contain an specific hashtag (#example) and also all the tweets from a certain user (#example)?
Looking for a single API call, that returns a JSON object with both those criteria.
I know I can do with two separate API calls, but I an trying to do this with one. Possibly https://dev.twitter.com/docs/api/1.1/get/search/tweets is the best bet.
When you use multiple terms together, Twitter search performs an AND operation by default. i.e.
https://dev.twitter.com/docs/api/1.1/get/search/tweets.json?q=from%3AJoeMayo%20%23twitterapi
Returns only tweets that are from JoeMayo and contain #twitterapi.
You can experiment with it on Twitter's Search page.
https://api.twitter.com/1.1/search/tweets.json?q=shrmi14
is the one that i used.
Incase you feel issues. refer https://dev.twitter.com/console for generating your own queries..
I see the request API docs here: https://dev.twitter.com/docs/api/1.1/get/search/tweets
I understand that there's a geocode field. The problem is that the query field is required meaning I have to search something that's related in that area. Is it possible to just get ALL the latest tweets around that area without specifying a query?
No, this is deliberate to prevent huge demand on the servers, you need to specify something else. My tip - use the date/time related query fields. This is acceptable, and if you really need "forever", you can make more requests.