How to download recent tweets regardless of keyword? I want any recent tweet from the Twitter API version 2. Is it possible? If it is, how to write a query?
For example, it will download tweets containing word cat:
https://api.twitter.com/2/tweets/search/recent?query=cat
but what query to use to use instead of ?? to get tweets for any keyword:
https://api.twitter.com/2/tweets/search/recent?query=??
In API1.1, it was possible to use * as a query, but it seems it is not working for API2. If I commit a query I get the following error: The query query parameter can not be empty.
I think this would return far too many results as it would be all Tweets from all users, all over the world! The "recent" endpoint will limit results to those from the last 7 days but it would still be millions.
You can query just the tweets from a particular account (e.g. Stackoverflow) with:
https://api.twitter.com/2/tweets/search/recent?query=from:stackoverflow
Related
I have access to Twitter API for Academic Research, and I'd like to get the follower count on a given date of a user, or at the time of a tweet.
The doc mentions that "This fields parameter enables you to select which specific user fields will deliver in each returned Tweet.", so I assumed that by adding public_metrics to the users.field, the number of followers can be seen in each returned Tweet, however, in each returned Tweet, I can only see user_id. https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference.
Is it even possible to achieve what I want with Twitter API for Academic Research? Is there any other approach to make it?
Thank you so much.
You cannot get the follower count on a specific date; it will always be the count at the time you make the API call.
You may need to add expansions to your API call in order to receive the values you are trying to pull out.
I would like to search for a tweets within a range of between dates by using Twitter API v1.1
let Query query=new QUery(String query);
what is the query thats suits for my question ??
Thanks in advance for reply back.
I suggest setting until to limit your query to an upper date bound, e.g.:
query.setUntil("2014-07-01");
Then step back through the result set, by making subsequent search calls, until you hit your lower date bound.
Be aware that the search API may not contain all Tweets and it may not 'go back' as far as you need. For more information on it, and other query parameters, take a look at Twitter's documentation on searching.
I am using this URL http://search.twitter.com/search.json to grab tweets with the hash tag #SameHashTag. The feed only returns items within the past week. Twitter explains why here:
https://dev.twitter.com/docs/faq#8650
I really need to get the last 10 tweets, regardless of when they were created. What is the alternative?
Note I read about user_timeline, but that seems to be based on user instead of hashtag. I read about list_timeline, but that seems to pull tweets from a defined list of users instead of hashtag.
You can't get old tweets from Search API. If your hashtag doesn't change you could search it and save results every day and build your own history.
I am using Google Documents List API for searching within documents.
Searching on the google drive ui returns results with most number of occurences of words first. But with api it returns the results with last uploaded date first.
This is the URL which i am using https://docs.google.com/feeds/default/private/full?q=search+term
I also tried with https://docs.google.com/feeds/default/private/full?q=search+term&desc=true but this gave the same results that we were getting earlier i.e. by last uploaded date first.
Can someone guide me with what additional parameters i should be adding to the url
You can use the orderBy query parameter to order the Documents List Feed by certain criteria:
last-modified: Default value, sort by last modified date.
last-accessed: sort by last accessed date.
title: sort by title (this is what you're looking for.
starred: sort documents by their "starred" attribute.
I'd like to retrieve the tweets for given a hashtag and sort them from the most retweeted to the less retweeted.
The closest thing I've found is using the search call and use the type tag:
E.g.: http://search.twitter.com/search.json?q=TheHashTagHere&result_type=popular
However, I'm not sure on how "popular" option works.
For instance, if it finds 100 tweets with that hashtag I believe it should show the X most retweeted tweets, and if none of those tweets have been retweeted then it should show X of them randomly (or sorted in some other way like the most recent).
Unfortunately, if follows some kind of unknown rule to identify what's popular and what not and even hashtags with thousands of tweets might return only one or two results.
I hope I made myself clear. Thanks in advance :)
PS: I'll use PHP but I think that shouldn't affect the question?
Results will sometimes contain a
result_type field into the metadata
with a value of either "recent" or
"popular". Popular results are derived
by an algorithm that Twitter computes,
and up to 3 will appear in the default
mixed mode that the Search API
operates under. Popular results
include another node in the metadata
called recent_retweets. This field
indicates how many retweets the Tweet
has had.
Source (Emphasis are mine)
Just call with result_type=popular and check the recent_retweets node to see how popular it is. result_type=popular will become the default in an upcome release so beware if you omit this parameter.
Results with popular tweets aren't ordered chronologically. *
If you would like to always have results to show, use result_type=mixed: they will have the result_type in the "metadata" section with a value of "recent", and popular results will have "popular". A small reference about result_types:
mixed: Include both popular and real time results in the response.
recent: return only the most recent results in the response
popular: return only the most popular results in the response.
If a search query has any popular results, those will be returned at the top, even if they are older than the other results. *
*[Twitter API Announcements]
This isn't a programmatic method but rather works in the browser with a chrome extension (HackyBird) :
Install the extension
Search for a phrase e.g. #Social (twitter.com/search?q=%23Social)
Click the extension to sort it (you can adjust the ratio of retweets/likes used for sorting in extension options).
P.S. It'll also sort your or any other user's timeline.