Getting tweet replies to a particular tweet from a particular user

I am trying to go through tweets of a particular user and get all replies on that tweet. I found that the APIv1.1 of twitter does not directly support it.

Is there a hack or a workaround on getting the replies for a particular tweet. I am using python Streaming API.

There is a workaround using the REST API.

You will need the id_str and @username of the author of the original tweet you want to find replies to.

You should use the Search API for the "@username" of the author. Go through the results looking for the 'in_reply_to_status_id' field to compare to the id_str of the specific tweet you want replies for.

How to get a list of replies to a specific tweet via Twitter API, Twitter's API doesn't allow you to get replies to a particular tweet. Strange. but true. But you can use Twitter's Search API to search for tweets that are. directed at � Tweet authors have the option to hide replies to their Tweets. Everyone can still access hidden replies through the hidden reply icon, which shows up on the original Tweet when there are hidden replies. Additionally, the Tweet author can unhide a reply at any time. When a Tweet author hides a reply, the author of the reply will not be notified.

Here's a work around to fetch replies of a tweet made by "username" using the rest API using tweepy

1) Find the tweet_id of the tweet for which the replies are required to be fetched

2) Using the api's search method query the following (q="@username", since_id=tweet_id) and retrieve all tweets since tweet_id

3) the results matching the in_reply_to_status_id to tweet_id is the replies for the post.

Try to get replies to a particular set of tweets, recursively. � GitHub, What's worse is that there is no Twitter API call to get the replies to a given tweet. If you have the JSON for a tweet in hand you can use the� I have build a flow using twitter connector to capture tweets from a particular user and send them to kaizala Connector. But its not working fine it seems.It seems its not taking that user. It is sending all tweets with that search term without filtering user. I want to send the new tweet created by that particular user to kaizala.

replies=[] 
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)  
for full_tweets in tweepy.Cursor(api.user_timeline,screen_name=name,timeout=999999).items(10):
  for tweet in tweepy.Cursor(api.search,q='to:'+name,result_type='recent',timeout=999999).items(1000):
    if hasattr(tweet, 'in_reply_to_status_id_str'):
      if (tweet.in_reply_to_status_id_str==full_tweets.id_str):
        replies.append(tweet.text)
  print("Tweet :",full_tweets.text.translate(non_bmp_map))
  for elements in replies:
       print("Replies :",elements)
  replies.clear()

The above code will fetch 10 recent tweets of an user(name) along with the replies to that particular tweet.The replies will be saved on to a list named replies. You can retrieve more tweets by increasing the items count (eg:items(100)).

Twitter Replies, In the following quick start guide, we will request this specific Tweet from @ TwitterDev There are a few methods for sending requests to the users endpoint . How can I get a users replies to another tweets and get the original tweet? I mean let assume user A replied to user B and user C. I want to retrieve all replies of A. So I want user B as original tweet and user A tweet as reply. And user C tweet as original tweet and user A reply to the original tweet.

Even after so many approaches and help, I spent around an hour figuring out the exact code to fetch replies to a tweet made by the original author. In addition to fetching the reply, twitter users' mostly reply to the reply to make a thread (which makes it different to fetch the entire thread made by the original author)

I've recently been working on a simple project which uploads the screenshot of every tweet in a thread of original author to your Google Photos. The most important part of being able to fetch reply to the tweets and reply to the replies

Here's a simple recursion that I wrote which solves my problem. This function update the urls list with the URLs of all the replies and replies to the replies of the author.

def update_urls(tweet, api, urls):
    tweet_id = tweet.id
    user_name = tweet.user.screen_name
    max_id = None
    replies = tweepy.Cursor(api.search, q='to:{}'.format(user_name),
                                since_id=tweet_id, max_id=max_id, tweet_mode='extended').items()

    for reply in replies:
        if(reply.in_reply_to_status_id == tweet_id):
            urls.append(get_twitter_url(user_name, reply.id))
            try:
                for reply_to_reply in update_urls(reply, api, urls):
                    pass
            except Exception:
                pass
        max_id = reply.id
    return urls

Here are some additional function that you might need if you plan to use the update_urls function.

def get_api():
    auth=tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_key, access_secret)
    api = tweepy.API(auth, wait_on_rate_limit=True)
    return api

def get_tweet(url):
    tweet_id = url.split('/')[-1]
    api = get_api()
    tweet = api.get_status(tweet_id)
    return tweet

def get_twitter_url(user_name, status_id):
    return "https://twitter.com/" + str(user_name) + "/status/" + str(status_id)

running the exact code:

api = get_api()
tweet = get_tweet(url)
urls = [url]
urls = update_urls(tweet, api, urls)

In case you want to fetch the content for a particular URL, just call get_tweet(url) and use the tweet object to get tweet.text, tweet.user, etc information. Let me know if it worked or didn't for you :)

GET /tweets | Docs, Lookup � Recent search � Filtered stream � Sampled stream � Hide replies To learn how to use Twitter Search effectively, please see the Standard search operators page for a list of available geocode, optional, Returns tweets by users located within a given radius of the given latitude/longitude. curl -- request GET --url� As of May 7th, 2013, Twitter's already deprecated v1.0 is being retired and v1.1 is the only method of accessing the API, using authenticated requests via OAuth.. This means you won't be able to use PHP's file_get_contents() entirely on it's own to grab this sort of thing - you need to write a script that utilises OAuth and Twitters v1.1 API.

Standard search API | Docs, So, for example, we will not consider GET statuses/retweets_of_me. The source of a Twitter client. It is generally used from the commandline, but we will use it as a library. Retrieve a single tweet from the Twitter API tweet� I know that Twitter API does not provide an endpoint to get replies of a tweet unless we have a premium account. But I could find some workarounds in the internet. I found a way to get few tweets and their replies using Getting tweet replies to a particular tweet from a particular user .

On retweets, replies, quotes & favorites: A guide for researchers , Twitter uses "@replies" to let users quickly reply to a statement or question left by someone else. or limit the results to specific Twitter accounts, languages, countries or cities. Type "GET username 40404" to get only that person's last tweet. Next, let’s iterate through the user’s Tweets using tweepy’s API.user_timeline(). Tweepy’s Cursor allows us to stream data from the query without having to manually query for more data in batches. The Twitter API will return around 3200 Tweets using this method (which can take a while).

How to See Replies on Twitter, You can use your Twitter bot to automate all or part of your Twitter activity. active with new tweets and retweets, following interesting accounts, and quickly replying to Keep in mind that Twitter imposes certain restrictions and policies about what you can and You can get started by creating a project called tweepy-bots . The Retweet with comment feature allows you to Tweet another person's Tweet with your own comment added. About replies sent from accounts with protected Tweets By protecting your Tweets (making them private), you're telling us that you don't want anyone to see any of your Tweets unless you've accepted their follow request.

Comments
  • Can you write the way you would program this?
  • how would you program this?