'Get conversation ID with Tweepy

Basically I want to get the conversation_id if the Tweet is a reply to another Tweet. So I can get the list of replies to each other to analyze.

My code:

class Listener(StreamingClient):

    def on_response(self, response):
        print(response)


listener = Listener(auth['bearer_token'])
listener.sample(expansions=['in_reply_to_user_id'], tweet_fields=['conversation_id'])

When using this, I only get the user_id to which it is replying, but I cannot get any type of conversation_id.

I have a slight feeling I am missing something essential.



Solution 1:[1]

From the relevant FAQ section about this in Tweepy's documentation:

If you are simply printing the objects and looking at that output, the string representations of API v2 models/objects only include the default fields that are guaranteed to exist.

The objects themselves still include the relevant data, which you can access as attributes or by subscription.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harmon758