Search code examples
pythonapitweepy

Tweepy api.get_status().in_reply_to_status_id_str returns None


No matter what tweet I use when I call myTweet.text it returns the text for the tweet I want but when I call myTweet.in_reply_to_status_id_str it returns None even if there are replies to the tweet.

Am I using it wrong? This is the only way I can find online of how to get the replies to a tweet. Thank you in advance for your help, the code:

api = tweepy.API(auth)

myTweet = api.get_status('id')
print(myTweet)

print(myTweet.text)
print('---', myTweet.in_reply_to_status_id_str)


Solution

  • The in_reply_to_status_id_str attribute will contain the string representation of the original Tweet’s ID if the represented Tweet is a reply. See https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object.

    Twitter's API does not have a direct method/endpoint to retrieve replies to a specific Tweet.
    Instead, you'll have to use the search APIs and filter the results manually.