DEV Community

Saadman Rafat
Saadman Rafat

Posted on

Twitter API v2: Hide Replies with Twitter-Stream.py

Twitter-Stream.py now supports Hide Replies. Set the environment variables as shown below. If you currently are not in possession of a developers.twitter.com account. Check out this list of apps curated by Twitter. You can use these applications to hide conversations.

Usage

~$ mkdir twitterStream && cd twitterStream
~$ pipenv install twitter-stream.py # or use pip3
~$ pipenv shell
(twitter-stream) ~$ export $API_KEY=API_KEY
(twitter-stream) ~$ export $API_KEY_SECRET=API_KEY_SECRET
(twitter-stream) ~$ export $ACCESS_TOKEN=ACCESS_TOKEN
(twitter-stream) ~$ export $ACCESS_TOKEN_SECRET=ACCESS_TOKEN_SECRET
(twitter-stream) ~$ touch stream.py
(twitter-stream) ~$ tree
├── Pipfile
└── Pipfile.lock
└── stream.py
0 directories, 3 files

Enter fullscreen mode Exit fullscreen mode

Enter the URL of the reply to your tweet you want to hide. The authorized user should be making the API call.

from twitter_stream import hide_replies

response = hide_replies(
    tweet: str = 'https://twitter.com/saadmanrafat_/status/1328288598106443776',
    hidden: dict = {"hidden": True} # or {"hidden": False} to unhide
)
print(response)
Enter fullscreen mode Exit fullscreen mode

OUTPUT:

 {
   "data": {
     "hidden": true 
   }
}
Enter fullscreen mode Exit fullscreen mode

Twitter-Stream.py also supports FilteredStream, SampledStream, RecentSearch, TweetLookUp, and UserLookUp. To get more insights into other API endpoints. Visit the examples folder and our documentations twitivity.dev.


docs : twitivity.dev/docs
github : https://github.com/saadmanrafat/twitter-stream.py
mail : mail@twitivity.dev
twitter: @twitivitydev
report an issue: Issues

Latest comments (0)