I want to get all the 'retweets with comments' of a tweet.
Here are few things I noticed with twitter api
Retweets with comments are treated as tweets. The retweet count does not increase if you add a comment, also the twitter message is "XYZ quoted you instead retweeted you'
You clearly can't use this API endpoint https://dev.twitter.com/rest/reference/post/statuses/retweet/:id
Is there a way to find all the 'tweet/retweet with comment' if you can supply the original Tweet/Id?
So you're referring to Quoted Tweets (retweet with comments). There is no official method for that from the REST API yet, however, there are couple of ways to do it.
Since all quoted tweets contain the short url to the original one,
you can still use in_reply_to_status_id and filter by short url of the original tweet
Search for tweets that contain the field quoted_status_id this can be done either through REST or STREAMING API.
quoted_status_id: This field only surfaces when the Tweet is a quote Tweet. This field contains the integer value Tweet ID of the quoted Tweet.
This isn't easy to accomplish. Here's the brute-force API method to find Quote Tweets.
Take your tweet id, it'll be something like 750176081987014657.
GET search/tweets
Use the Twitter API and search for the tweet.
https://dev.twitter.com/rest/reference/get/search/tweets
The GET request will look something like this:
https://api.twitter.com/1.1/search/tweets.json?q=750176081987014657&count=100
The q "query" argument is the tweet id. I've set the result count argument to the maximum (100).
Authorization
Of course with the Twitter API there's a whole bunch of tricky Authorization header work you have to do as well in order to complete the GET request. That's documented elsewhere and is beyond the scope of this answer.
Results and Conclusion
When you have the JSON results of this GET request, focus on the statuses collection. For each tweet in the collection (otherwise known as a "status"), check if it contains a quoted_status_id field. If it does, and the field value matches your tweet id, the tweet is a quote tweet. If it does not, it is simply a retweet with no added comment. You will also have to deal with iterating through the pagination of results if there are more than 100. That's done by looking for a search_metadata.next_results field and retrieving the next GET query string from it, which will be provided for you.
In the Twitter Api is there anything in the response that tells if the Tweet has been flagged as NSFW or inappropriate? The response is quite big but I couldn't find anything in it that flags the Tweet as NSFW.
There is a possibly_sensitive flag in the Twitter API, tweet object.
possibly_sensitive Boolean Nullable. This field only surfaces when a
tweet contains a link. The meaning of the field doesn’t pertain to the
tweet content itself, but instead it is an indicator that the URL
contained in the tweet may contain content or media identified as
sensitive content.
Example:
"possibly_sensitive":true
I have found this question. However I think this has changed on API version 1.1.
If I use the search/tweets method, how can I see if the tweet is a RT?
I see that the retweeted field always returns false. Is there another field I can use for this answer?
If it's a retweet, the tweet will contain a property named retweeted_status. To be complete, retweeted_status will not appear if the tweet is not a retweet. More info at: Tweets.
By simply checking the property name
"retweeted_status"
if you does not find then it's not RT.
As #Joe Mayo said, check for the retweeted_status key on the status object.
I have an example that is not caught by #Apoorv Ashutosh's suggestion.
See: https://twitter.com/gppvt/status/474162466776449024 this will redirect (because it is a retweet) to the original tweet. However if you get this tweet through the twitter API, it has retweeted_status. Notice the text does not contain "RT".
The retweeted field is false if the retweet is not done using the retweet button but rahter via RT, so in such a case, just search the "text" field of all tweets for this pattern
RT #
This pattern can be of help, but I don't think there is any other function for this.
The retweeted_status property will exist if the received tweet was retweeted, else you will get the AttributeError error. In the case, you want to get rid of retweeted tweets:
def on_status(self, status):
try:
print "Retweeted ************* \n" + str(status.retweeted_status)
return
except AttributeError:
print "there is no attribut with name retweeted_status"
Just to add a bit more. (using twitter gem (ruby language))
You can check if its a retweet by checking the tweet and then getting what you need from the retweeted_status hash
t = client.status(#########) #function that obtains tweet based on ID where # = tweet ID
puts t.retweeted_status? # returns true or false
t.retweeted_status # returns the actual hash for that
As everyone else has mentioned, you can check to see if the retweeted_status property exists in the response subfield for that Tweet.
However, per the current version of the API, every Tweet object has the field retweeted that stores a boolean value (True or False) that will tell you if a Tweet has been retweeted.
Make sure your "re-tweet" is not actually a quote of an another tweet. In this case, I had to use the quoted_status field to get the original tweet, rather than the retweeted_status one.
To the ones who are using Hydrator1 and relying on its CSV export of the hydrated JSONL file: you can check reweet_id (no it's not a typo in version 0.0.12), and if it's NA then it's an original tweet as I found.
original_twitter_tweets = twitter_csv_data %>% filter(is.na(reweet_id))
I've noticed that retweets are distinguished from regular tweets by the line "RT #..."
The Python code following can be used to identify them:
tweettext = str( tweet.text.lower())
if tweettext.startswith("rt #") == True:
print(tweet.id)
Tweet object is the tweet variable.
Tweepy is another tool you may use to manage the Twitter API more easily.
I want to get all retweets, that similar to current retweet.
What I mean:
If someone makes retweet, I want to take his tweet id (retweet id) and take all retweets of original tweet, that user retweet.
So: original tweet -> user_retweet_id
get statuses/retweets/user_retweet_id.json
/*as statuses/retweets/original_tweet_id*/
Is it possible?
P.S: I ask it because if I took general information about retweet (user_retweet_id), I get an information about original tweet (retweet_count), but I can't get retweets from it for original tweet.
As far as I know there is no information for getting retweet of a retweet, as essentially you are retweeting the original post. Just retweet an already existing retweet and you will see that you will actually retweeted the original tweet without leaving any mark about the intermediate step.
There's no direct method for that but what you can do is
Extract main username of user who actually posted that tweet
Extract his timeline using twitter.showTimeline()
Then find your tweet using String matching
This will give you original tweet ID
Then you can find most 100 recent retweets using that oiginal tweet ID
I am using twitter4j for this
May I know how do I get latest tweet by specific user and specific hashtag
On twitter GET Search no parameters option for the username or userid
Let's say I want to search tweet from username stackoverflow with #php hashtag.
You would have to custom code the second part.
Use https://dev.twitter.com/docs/api/1/get/statuses/user_timeline - to get the latest tweets from a specific user.
Write Code to search within the response Object of (1) with the hashtag (search-key).