Replies to a particular tweet, Twitter API

The Twitter API v2 supports this now using a conversation_id field. You can read more in the docs.

First, request the conversation_id field of the tweet.

https://api.twitter.com/2/tweets?ids=1225917697675886593&tweet.fields=conversation_id

Second, then search tweets using the conversation_id as the query.

https://api.twitter.com/2/tweets/search/recent?query=conversation_id:1225912275971657728

This is a minimal example, so you should add other fields as you need to the URL.


Twitter has an undocumented api called related_results. It will give you replies for the specified tweet id. Not sure how reliable it is as its experimental, however this is the same api call that is called on twitter web.

Use at your own risk. :)

https://api.twitter.com/1/related_results/show/172019363942117377.json?include_entities=1

For more info, check out this discussion on dev.twitter: https://dev.twitter.com/discussions/293


From what I understand, there's not a way to do that directly (at least not now). Seems like something that should be added. They recently added some 'retweet' capabilities, seem logical to add this as well.

Here's one possible way to do this, first sample tweet data (from status/show):

<status>
  <created_at>Tue Apr 07 22:52:51 +0000 2009</created_at>
  <id>1472669360</id>
  <text>At least I can get your humor through tweets. RT @abdur: I don't mean this in a bad way, but genetically speaking your a cul-de-sac.</text>
  <source><a href="http://www.tweetdeck.com/">TweetDeck</a></source>
  <truncated>false</truncated>
  <in_reply_to_status_id></in_reply_to_status_id>
  <in_reply_to_user_id></in_reply_to_user_id>
  <favorited>false</favorited>
  <in_reply_to_screen_name></in_reply_to_screen_name>
  <user>
    <id>1401881</id>
     ...

From status/show you can find the user's id. Then statuses/mentions_timeline will return a list of status for a user. Just parse that return looking for a in_reply_to_status_id matching the original tweet's id.


Here is the procedure to get the replies for a tweets

  1. when you fetch the tweet store the tweetId ie., id_str
  2. using twitter search api do the following query [q="to:$tweeterusername", sinceId = $tweetId]
  3. Loop all the results , the results matching the in_reply_to_status_id_str to $tweetid is the replies for the post.

Tags:

Twitter