'How to store data from StreamingClient.filter() or .sample() from the Tweepy Module Twitter API v2

I want to store Tweets that have certain hashtags such as #cats for example. I can pull the 10 most recent Tweets by executing client.search_recent_tweets(query="cats"), but then when I set up an object from the StreamingClient class and I try to use the .filter() and .sample() method I can't seem to get any data...

I'm using a Juypter Notebook, and my code looks like this:

streaming_client = tweepy.StreamingClient(bearer_token=twitter_keys.bearer_token)
streaming_client.sample()
streaming_client.disconnect()

I don't know if I need to store what the stream is retrieving inside a variable or do something else. I've been rereading the Tweepy 4.9.0 documentation but I can't find anything online that seems to answer my question, not to mention when I run the filter() and sample() methods my kernel just keeps running. I'm just confused.



Solution 1:[1]

By default, only StreamingClient.on_response() logs the data received, at the DEBUG logging level.

To customize the processing of the stream data, StreamingClient needs to be subclassed.

https://tweepy.readthedocs.io/en/v4.9.0/streaming.html#using-streamingclient

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